Skip to content

Commit

Permalink
Drop support for npm v4
Browse files Browse the repository at this point in the history
  • Loading branch information
bertdeblock committed Sep 5, 2023
1 parent b0f477b commit b6f51aa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 85 deletions.
11 changes: 0 additions & 11 deletions lib/dependency-manager-adapters/npm.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,17 +136,6 @@ module.exports = CoreObject.extend({
debug('Run npm/yarn install with options %s', mgrOptions);

await this.run(cmd, [].concat(['install'], mgrOptions), { cwd: this.cwd });

if (!this.useYarnCommand) {
let res = await this.run('npm', ['--version'], { cwd: this.cwd, stdio: 'pipe' });
let version = res.stdout;
if (version.match(/^4./)) {
debug('Running npm prune because version is %s', version);
return await this.run(this.configKey, ['prune'], { cwd: this.cwd });
}

debug('Not running npm prune because version is %s', version);
}
},

applyDependencySet(depSet) {
Expand Down
79 changes: 5 additions & 74 deletions test/dependency-manager-adapters/npm-adapter-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ describe('npmAdapter', () => {

describe('#_install', () => {
describe('without yarn', () => {
it('only runs npm install with npm 5', async () => {
it('runs npm install', async () => {
writeJSONFile('package.json', fixturePackage);
let runCount = 0;
let stubbedRun = generateMockRun(
Expand All @@ -80,54 +80,6 @@ describe('npmAdapter', () => {
return RSVP.resolve();
},
},
{
command: 'npm --version',
callback() {
runCount++;
return RSVP.resolve({ stdout: '5.7.1' });
},
},
],
{ allowPassthrough: false }
);

let adapter = new NpmAdapter({
cwd: tmpdir,
run: stubbedRun,
});

await adapter._install();
expect(runCount).to.equal(2);
});

it('runs npm prune and npm install with npm 4', async () => {
writeJSONFile('package.json', fixturePackage);
let runCount = 0;
let stubbedRun = generateMockRun(
[
{
command: 'npm install --no-shrinkwrap',
callback(command, args, opts) {
runCount++;
expect(opts).to.have.property('cwd', tmpdir);
return RSVP.resolve();
},
},
{
command: 'npm prune',
callback(command, args, opts) {
runCount++;
expect(opts).to.have.property('cwd', tmpdir);
return RSVP.resolve();
},
},
{
command: 'npm --version',
callback() {
runCount++;
return RSVP.resolve({ stdout: '4.7.1' });
},
},
],
{ allowPassthrough: false }
);
Expand All @@ -138,7 +90,7 @@ describe('npmAdapter', () => {
});

await adapter._install();
expect(runCount).to.equal(3, 'All three commands should run');
expect(runCount).to.equal(1);
});

it('uses managerOptions for npm commands', async () => {
Expand All @@ -153,13 +105,6 @@ describe('npmAdapter', () => {
return RSVP.resolve();
},
},
{
command: 'npm --version',
callback() {
runCount++;
return RSVP.resolve({ stdout: '5.7.1' });
},
},
],
{ allowPassthrough: false }
);
Expand All @@ -171,7 +116,7 @@ describe('npmAdapter', () => {
});

await adapter._install();
expect(runCount).to.equal(2);
expect(runCount).to.equal(1);
});

it('uses buildManagerOptions for npm commands', async () => {
Expand All @@ -186,13 +131,6 @@ describe('npmAdapter', () => {
return RSVP.resolve();
},
},
{
command: 'npm --version',
callback() {
runCount++;
return RSVP.resolve({ stdout: '5.7.1' });
},
},
],
{ allowPassthrough: false }
);
Expand All @@ -206,7 +144,7 @@ describe('npmAdapter', () => {
});

await adapter._install();
expect(runCount).to.equal(2, 'npm install should run with buildManagerOptions');
expect(runCount).to.equal(1, 'npm install should run with buildManagerOptions');
});

it('throws an error if buildManagerOptions does not return an array', async () => {
Expand Down Expand Up @@ -382,13 +320,6 @@ describe('npmAdapter', () => {
return Promise.resolve();
},
},
{
command: 'npm --version',
callback() {
runCount++;
return RSVP.resolve({ stdout: '10.0.0' });
},
},
],
{ allowPassthrough: false }
);
Expand All @@ -400,7 +331,7 @@ describe('npmAdapter', () => {

await adapter._restoreOriginalDependencies();

expect(runCount).to.equal(2);
expect(runCount).to.equal(1);
});
});

Expand Down

0 comments on commit b6f51aa

Please sign in to comment.