Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use --no-package-lock in npm #961

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions lib/dependency-manager-adapters/npm.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,14 @@ module.exports = CoreObject.extend({
if (mgrOptions.indexOf('--ignore-engines') === -1) {
mgrOptions = mgrOptions.concat(['--ignore-engines']);
}
} else if (mgrOptions.indexOf('--no-shrinkwrap') === -1) {
mgrOptions = mgrOptions.concat(['--no-shrinkwrap']);
} else if (mgrOptions.indexOf('--no-package-lock') === -1) {
let res = await this.run('npm', ['--version'], { cwd: this.cwd, stdio: 'pipe' });
let version = res.stdout;
if (version.match(/^4./)) {
mgrOptions = mgrOptions.concat(['--no-shrinkwrap']);
} else {
mgrOptions = mgrOptions.concat(['--no-package-lock']);
}
}
}

Expand Down
13 changes: 8 additions & 5 deletions test/dependency-manager-adapters/npm-adapter-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ describe('npmAdapter', () => {
let stubbedRun = generateMockRun(
[
{
command: 'npm install --no-shrinkwrap',
command: 'npm install --no-package-lock',
callback(command, args, opts) {
runCount++;
expect(opts).to.have.property('cwd', tmpdir);
Expand All @@ -105,7 +105,8 @@ describe('npmAdapter', () => {
});

await adapter._install();
expect(runCount).to.equal(2);
// checking for 3 commands because install checks for npm version too
expect(runCount).to.equal(3, 'both commands run');
});

it('runs npm prune and npm install with npm 4', async () => {
Expand Down Expand Up @@ -146,7 +147,8 @@ describe('npmAdapter', () => {
});

await adapter._install();
expect(runCount).to.equal(3, 'All three commands should run');
// checking for 4 commands because install checks for npm version too
expect(runCount).to.equal(4, 'All three commands should run');
});

it('uses managerOptions for npm commands', async () => {
Expand All @@ -155,7 +157,7 @@ describe('npmAdapter', () => {
let stubbedRun = generateMockRun(
[
{
command: 'npm install --no-optional --no-shrinkwrap',
command: 'npm install --no-optional --no-package-lock',
callback() {
runCount++;
return RSVP.resolve();
Expand All @@ -179,7 +181,8 @@ describe('npmAdapter', () => {
});

await adapter._install();
expect(runCount).to.equal(2);
// checking for 3 commands because install checks for npm version too
expect(runCount).to.equal(3, 'both commands run');
});

it('uses buildManagerOptions for npm commands', async () => {
Expand Down