Skip to content
Permalink
Browse files

feat(packager): remove the users forge config after packaging for saf…

…ety reasons

ISSUES CLOSED: #133
  • Loading branch information
MarshallOfSound authored and malept committed Feb 16, 2017
1 parent efc7ea1 commit 7432e03435ee97c0268d34e8c27aa8df6739dceb
Showing with 22 additions and 0 deletions.
  1. +7 −0 src/api/package.js
  2. +15 −0 test/slow/api_spec_slow.js
@@ -81,6 +81,13 @@ export default async (providedOptions = {}) => {
await rebuildHook(buildPath, electronVersion, pPlatform, pArch);
packagerSpinner = ora('Packaging Application').start();
done();
}, async (buildPath, electronVersion, pPlatform, pArch, done) => {
const copiedPackageJSON = await readPackageJSON(buildPath);
if (copiedPackageJSON.config && copiedPackageJSON.config.forge) {
delete copiedPackageJSON.config.forge;
}
await fs.writeFile(path.resolve(buildPath, 'package.json'), JSON.stringify(copiedPackageJSON, null, 2));
done();
}].concat(forgeConfig.electronPackagerConfig.afterCopy ? forgeConfig.electronPackagerConfig.afterCopy.map(item =>
(typeof item === 'string' ? requireSearch(dir, [item]) : item)
) : []),
@@ -152,6 +152,9 @@ describe(`electron-forge API (with installer=${installer.substr(12)})`, () => {
dir = path.resolve(os.tmpdir(), `electron-forge-test-${dirID}/electron-forge-test`);
dirID += 1;
await forge.init({ dir });
const newPackageJSON = await readPackageJSON(dir);
newPackageJSON.config.forge.electronPackagerConfig.asar = false;
await fs.writeFile(path.resolve(dir, 'package.json'), JSON.stringify(newPackageJSON, null, 2));
});

it('can package without errors', async () => {
@@ -164,6 +167,18 @@ describe(`electron-forge API (with installer=${installer.substr(12)})`, () => {
});

describe('after package', () => {
it('should have deleted the forge config from the packaged app', async () => {
const cleanPackageJSON = await readPackageJSON(
path.resolve(dir, 'out', `electron-forge-test-${process.platform}-${process.arch}`, 'electron-forge-test.app', 'Contents', 'Resources', 'app')
);
expect(cleanPackageJSON).to.not.have.deep.property('config.forge');
});

it('should not affect the actual forge config', async () => {
const normalPackageJSON = await readPackageJSON(dir);
expect(normalPackageJSON).to.have.deep.property('config.forge');
});

let targets = [];
if (fs.existsSync(path.resolve(__dirname, `../../src/makers/${process.platform}`))) {
targets = fs.readdirSync(path.resolve(__dirname, `../../src/makers/${process.platform}`)).map(file => path.parse(file).name);

0 comments on commit 7432e03

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