Skip to content
Permalink
Browse files

fix(maker-dmg): return correct path from dmg maker (#631)

* fix(maker-dmg): return correct path from dmg maker

ISSUES CLOSED: #626

* Fix tests
  • Loading branch information
MarshallOfSound committed Nov 18, 2018
1 parent 01e715f commit b6c523c973e1d6a50a0ac759390baae4234d3d9a
@@ -23,8 +23,7 @@
"dependencies": {
"@electron-forge/maker-base": "6.0.0-beta.29",
"@electron-forge/shared-types": "6.0.0-beta.29",
"fs-extra": "^7.0.0",
"pify": "^4.0.0"
"fs-extra": "^7.0.0"
},
"optionalDependencies": {
"electron-installer-dmg": "^2.0.0"
@@ -5,7 +5,6 @@ import { MakerDMGConfig } from './Config';

import fs from 'fs-extra';
import path from 'path';
import pify from 'pify';

export default class MakerDMG extends MakerBase<MakerDMGConfig> {
name = 'dmg';
@@ -24,7 +23,8 @@ export default class MakerDMG extends MakerBase<MakerDMGConfig> {
const electronDMG = require('electron-installer-dmg');

const outPath = path.resolve(makeDir, `${this.config.name || appName}.dmg`);
const wantedOutPath = path.resolve(makeDir, `${appName}-${packageJSON.version}.dmg`);
const forgeDefaultOutPath = path.resolve(makeDir, `${appName}-${packageJSON.version}.dmg`);

await this.ensureFile(outPath);
const dmgConfig = Object.assign({
overwrite: true,
@@ -33,10 +33,13 @@ export default class MakerDMG extends MakerBase<MakerDMGConfig> {
appPath: path.resolve(dir, `${appName}.app`),
out: path.dirname(outPath),
});
await pify(electronDMG)(dmgConfig);
const opts = await electronDMG.p(dmgConfig);
if (!this.config.name) {
await fs.rename(outPath, wantedOutPath);
await this.ensureFile(forgeDefaultOutPath);
await fs.rename(outPath, forgeDefaultOutPath);
return [forgeDefaultOutPath];
}
return [wantedOutPath];

return [opts.dmgPath];
}
}
@@ -26,13 +26,13 @@ describe('MakerDMG', () => {

beforeEach(() => {
ensureFileStub = stub().returns(Promise.resolve());
eidStub = stub().callsArg(1);
eidStub = stub().returns(Promise.resolve({ dmgPath: '/path/to/dmg' }));
renameStub = stub().returns(Promise.resolve());
config = {};

MakerDMG = proxyquire.noPreserveCache().noCallThru().load('../src/MakerDMG', {
'../../util/ensure-output': { ensureFile: ensureFileStub },
'electron-installer-dmg': eidStub,
'electron-installer-dmg': { p: eidStub },
'fs-extra': {
rename: renameStub,
},

0 comments on commit b6c523c

Please sign in to comment.
You can’t perform that action at this time.