Skip to content

Commit

Permalink
fix: ensure that makers do not overwrite existing un-similar outputs (#…
Browse files Browse the repository at this point in the history
…1086)

Fixes #1081.
  • Loading branch information
MarshallOfSound authored and malept committed Aug 12, 2019
1 parent c9bfa11 commit dbc19d8
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 15 deletions.
2 changes: 1 addition & 1 deletion packages/maker/deb/src/MakerDeb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default class MakerDeb extends MakerBase<MakerDebConfig> {
// eslint-disable-next-line global-require, import/no-unresolved
const installer = require('electron-installer-debian');

const outDir = path.resolve(makeDir);
const outDir = path.resolve(makeDir, 'deb', targetArch);

await this.ensureDirectory(outDir);
const { packagePaths } = await installer({
Expand Down
4 changes: 2 additions & 2 deletions packages/maker/deb/test/MakerDeb_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe('MakerDeb', () => {
arch: debianArch(process.arch as ForgeArch),
options: {},
src: dir,
dest: makeDir,
dest: path.join(makeDir, 'deb', process.arch),
rename: undefined,
});
expect(maker.config).to.deep.equal(config);
Expand All @@ -80,7 +80,7 @@ describe('MakerDeb', () => {
productName: 'Debian',
},
src: dir,
dest: makeDir,
dest: path.join(makeDir, 'deb', process.arch),
rename: undefined,
});
});
Expand Down
2 changes: 1 addition & 1 deletion packages/maker/flatpak/src/MakerFlatpak.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default class MakerFlatpak extends MakerBase<MakerFlatpakConfig> {
const installer = require('@malept/electron-installer-flatpak');

const arch = flatpakArch(targetArch);
const outDir = path.resolve(makeDir, 'flatpak');
const outDir = path.resolve(makeDir, 'flatpak', arch);

await this.ensureDirectory(outDir);
const flatpakConfig = Object.assign({}, this.config, {
Expand Down
10 changes: 6 additions & 4 deletions packages/maker/flatpak/test/MakerFlatpak_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,11 @@ describe('MakerFlatpak', () => {
dir, makeDir, appName, targetArch, packageJSON,
});
const opts = eifStub.firstCall.args[0];
const expectedArch = flatpakArch(process.arch as ForgeArch);
expect(opts).to.deep.equal({
arch: flatpakArch(process.arch as ForgeArch),
arch: expectedArch,
src: dir,
dest: path.resolve(makeDir, 'flatpak'),
dest: path.resolve(makeDir, 'flatpak', expectedArch),
});
});

Expand All @@ -72,13 +73,14 @@ describe('MakerFlatpak', () => {
dir, makeDir, appName, targetArch, packageJSON,
});
const opts = eifStub.firstCall.args[0];
const expectedArch = flatpakArch(process.arch as ForgeArch);
expect(opts).to.deep.equal({
arch: flatpakArch(process.arch as ForgeArch),
arch: expectedArch,
options: {
productName: 'Flatpak',
},
src: dir,
dest: path.resolve(makeDir, 'flatpak'),
dest: path.resolve(makeDir, 'flatpak', expectedArch),
});
});
});
2 changes: 1 addition & 1 deletion packages/maker/rpm/src/MakerRpm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default class MakerRpm extends MakerBase<MakerRpmConfig> {
// eslint-disable-next-line global-require, import/no-unresolved
const installer = require('electron-installer-redhat');

const outDir = path.resolve(makeDir);
const outDir = path.resolve(makeDir, 'rpm', targetArch);

await this.ensureDirectory(outDir);
const { packagePaths } = await installer({
Expand Down
4 changes: 2 additions & 2 deletions packages/maker/rpm/test/MakerRpm_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe('MakerRpm', () => {
expect(opts).to.deep.equal({
arch: rpmArch(process.arch as ForgeArch),
src: dir,
dest: makeDir,
dest: path.join(makeDir, 'rpm', process.arch),
rename: undefined,
});
});
Expand All @@ -77,7 +77,7 @@ describe('MakerRpm', () => {
productName: 'Redhat',
},
src: dir,
dest: makeDir,
dest: path.join(makeDir, 'rpm', process.arch),
rename: undefined,
});
});
Expand Down
2 changes: 1 addition & 1 deletion packages/maker/snap/src/MakerSnap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default class MakerSnap extends MakerBase<MakerSnapConfig> {
// eslint-disable-next-line global-require
const installer = require('electron-installer-snap');

const outPath = path.resolve(makeDir, 'snap');
const outPath = path.resolve(makeDir, 'snap', targetArch);

await this.ensureDirectory(outPath);

Expand Down
4 changes: 2 additions & 2 deletions packages/maker/snap/test/MakerSnap_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe('MakerSnap', () => {
expect(opts).to.deep.equal({
arch: process.arch,
src: dir,
dest: path.resolve(makeDir, 'snap'),
dest: path.resolve(makeDir, 'snap', process.arch),
});
});

Expand All @@ -69,7 +69,7 @@ describe('MakerSnap', () => {
expect(opts).to.deep.equal({
arch: process.arch,
src: dir,
dest: path.resolve(makeDir, 'snap'),
dest: path.resolve(makeDir, 'snap', process.arch),
description: 'Snap description',
});
});
Expand Down
3 changes: 2 additions & 1 deletion packages/maker/zip/src/MakerZIP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@ export default class MakerZIP extends MakerBase<MakerZIPConfig> {
makeDir,
appName,
packageJSON,
targetArch,
targetPlatform,
}: MakerOptions) {
// eslint-disable-next-line global-require
const { zip } = require('cross-zip');

const zipDir = ['darwin', 'mas'].includes(targetPlatform) ? path.resolve(dir, `${appName}.app`) : dir;

const zipPath = path.resolve(makeDir, `${path.basename(dir)}-${packageJSON.version}.zip`);
const zipPath = path.resolve(makeDir, 'zip', targetPlatform, targetArch, `${path.basename(dir)}-${packageJSON.version}.zip`);

await this.ensureFile(zipPath);
await promisify(zip)(zipDir, zipPath);
Expand Down

0 comments on commit dbc19d8

Please sign in to comment.