From 6c8b70c847b90fdfd8c507dd3df4d129799c040f Mon Sep 17 00:00:00 2001 From: Samuel Attard Date: Sat, 17 Nov 2018 19:12:48 +1100 Subject: [PATCH 1/2] fix(maker-dmg): return correct path from dmg maker ISSUES CLOSED: #626 --- packages/maker/dmg/package.json | 3 +-- packages/maker/dmg/src/MakerDMG.ts | 13 ++++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/maker/dmg/package.json b/packages/maker/dmg/package.json index e959781ad6..7528d911cd 100644 --- a/packages/maker/dmg/package.json +++ b/packages/maker/dmg/package.json @@ -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" diff --git a/packages/maker/dmg/src/MakerDMG.ts b/packages/maker/dmg/src/MakerDMG.ts index ac20b3dd47..9e45ce001f 100644 --- a/packages/maker/dmg/src/MakerDMG.ts +++ b/packages/maker/dmg/src/MakerDMG.ts @@ -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 { name = 'dmg'; @@ -24,7 +23,8 @@ export default class MakerDMG extends MakerBase { 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 { 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]; } } From ef43f0de82eec568ba3b6284db9c1c25ba6d6cff Mon Sep 17 00:00:00 2001 From: Mark Lee Date: Sat, 17 Nov 2018 10:49:31 -0800 Subject: [PATCH 2/2] Fix tests --- packages/maker/dmg/test/MakerDMG_spec.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/maker/dmg/test/MakerDMG_spec.ts b/packages/maker/dmg/test/MakerDMG_spec.ts index 34686f8fe1..44ea719d49 100644 --- a/packages/maker/dmg/test/MakerDMG_spec.ts +++ b/packages/maker/dmg/test/MakerDMG_spec.ts @@ -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, },