Skip to content

Commit

Permalink
fix(core-utils): don't add --save flag for npm install (#3795)
Browse files Browse the repository at this point in the history
  • Loading branch information
erickzhao authored Jan 3, 2025
1 parent 2199fce commit 848aaa7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
3 changes: 1 addition & 2 deletions packages/api/core/src/util/install-dependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ export default async (dir: string, deps: string[], depType = DepType.PROD, versi
if (depType === DepType.DEV) cmd.push('--dev');
if (versionRestriction === DepVersionRestriction.EXACT) cmd.push('--exact');
} else {
if (versionRestriction === DepVersionRestriction.EXACT) cmd.push('--save-exact');
if (depType === DepType.DEV) cmd.push('--save-dev');
if (depType === DepType.PROD) cmd.push('--save');
if (versionRestriction === DepVersionRestriction.EXACT) cmd.push('--save-exact');
}
d('executing', JSON.stringify(cmd), 'in:', dir);
try {
Expand Down
6 changes: 3 additions & 3 deletions packages/api/core/test/fast/install-dependencies_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ describe('Install dependencies', () => {

it('should install prod deps', () => {
install('mydir', ['react']);
expect(spawnSpy.firstCall.args[0]).to.be.deep.equal(['install', 'react', '--save']);
expect(spawnSpy.firstCall.args[0]).to.be.deep.equal(['install', 'react']);
});

it('should install dev deps', () => {
Expand All @@ -88,12 +88,12 @@ describe('Install dependencies', () => {

it('should install exact deps', () => {
install('mydir', ['react-dom'], DepType.PROD, DepVersionRestriction.EXACT);
expect(spawnSpy.firstCall.args[0]).to.be.deep.equal(['install', 'react-dom', '--save-exact', '--save']);
expect(spawnSpy.firstCall.args[0]).to.be.deep.equal(['install', 'react-dom', '--save-exact']);
});

it('should install exact dev deps', () => {
install('mydir', ['mocha'], DepType.DEV, DepVersionRestriction.EXACT);
expect(spawnSpy.firstCall.args[0]).to.be.deep.equal(['install', 'mocha', '--save-exact', '--save-dev']);
expect(spawnSpy.firstCall.args[0]).to.be.deep.equal(['install', 'mocha', '--save-dev', '--save-exact']);
});
});
});

0 comments on commit 848aaa7

Please sign in to comment.