Skip to content

Commit

Permalink
Make copies of the dep lists instead of altering in-place
Browse files Browse the repository at this point in the history
  • Loading branch information
malept committed Jan 9, 2019
1 parent a74169e commit 1709af0
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/api/core/src/util/electron-version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,19 @@ export function getElectronVersion(packageJSON: any) {
}

export function updateElectronDependency(packageJSON: any, dev: string[], exact: string[]): [string[], string[]] {
const alteredDev = ([] as string[]).concat(dev);
let alteredExact = ([] as string[]).concat(exact);
if (Object.keys(packageJSON.devDependencies).find(findElectronDep)) {
exact = exact.filter(dep => dep !== 'electron');
alteredExact = alteredExact.filter(dep => dep !== 'electron');
} else {
const electronKey = Object.keys(packageJSON.dependencies).find(findElectronDep);
if (electronKey) {
exact = exact.filter(dep => dep !== 'electron');
alteredExact = alteredExact.filter(dep => dep !== 'electron');
d(`Moving ${electronKey} from dependencies to devDependencies`);
dev.push(`${electronKey}@${packageJSON.dependencies[electronKey]}`);
alteredDev.push(`${electronKey}@${packageJSON.dependencies[electronKey]}`);
delete packageJSON.dependencies[electronKey];
}
}

return [dev, exact];
return [alteredDev, alteredExact];
}

0 comments on commit 1709af0

Please sign in to comment.