Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Nov 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions packages/maker/dmg/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
13 changes: 8 additions & 5 deletions packages/maker/dmg/src/MakerDMG.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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,
Expand All @@ -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];
}
}
4 changes: 2 additions & 2 deletions packages/maker/dmg/test/MakerDMG_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down