fix: remove extraneous devDependencies on package merge

/cc @pitaj
isekai-main
Julian Lam 3 years ago
parent 9e4147f07c
commit a2c7d69e1b

@ -38,11 +38,12 @@ pkgInstall.updatePackageFile = () => {
}
});
const { devDependencies } = defaultPackageContents;
// Sort dependencies alphabetically
dependencies = sortDependencies({ ...dependencies, ...defaultPackageContents.dependencies });
const packageContents = { ..._.merge(oldPackageContents, defaultPackageContents), dependencies };
const packageContents = { ..._.merge(oldPackageContents, defaultPackageContents), dependencies, devDependencies };
fs.writeFileSync(paths.currentPackage, JSON.stringify(packageContents, null, 2));
};

@ -86,6 +86,15 @@ describe('Package install lib', () => {
assert.strictEqual(updated.scripts.preinstall, 'echo "What are you?";');
});
it('should remove extraneous devDependencies', async () => {
current.devDependencies.expect = '27.5.1';
await fs.writeFile(packageFilePath, JSON.stringify(current, null, 4));
pkgInstall.updatePackageFile();
const updated = JSON.parse(await fs.readFile(packageFilePath, 'utf8'));
assert.strictEqual(updated.devDependencies.hasOwnProperty('expect'), false);
});
after(async () => {
// Clean up
await fs.rename(path.resolve(__dirname, '../install/package.json.bak'), sourcePackagePath);

Loading…
Cancel
Save