Skip to content

Commit b6f51aa

Browse files
committed
Drop support for npm v4
1 parent b0f477b commit b6f51aa

2 files changed

Lines changed: 5 additions & 85 deletions

File tree

lib/dependency-manager-adapters/npm.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -136,17 +136,6 @@ module.exports = CoreObject.extend({
136136
debug('Run npm/yarn install with options %s', mgrOptions);
137137

138138
await this.run(cmd, [].concat(['install'], mgrOptions), { cwd: this.cwd });
139-
140-
if (!this.useYarnCommand) {
141-
let res = await this.run('npm', ['--version'], { cwd: this.cwd, stdio: 'pipe' });
142-
let version = res.stdout;
143-
if (version.match(/^4./)) {
144-
debug('Running npm prune because version is %s', version);
145-
return await this.run(this.configKey, ['prune'], { cwd: this.cwd });
146-
}
147-
148-
debug('Not running npm prune because version is %s', version);
149-
}
150139
},
151140

152141
applyDependencySet(depSet) {

test/dependency-manager-adapters/npm-adapter-test.js

Lines changed: 5 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ describe('npmAdapter', () => {
6767

6868
describe('#_install', () => {
6969
describe('without yarn', () => {
70-
it('only runs npm install with npm 5', async () => {
70+
it('runs npm install', async () => {
7171
writeJSONFile('package.json', fixturePackage);
7272
let runCount = 0;
7373
let stubbedRun = generateMockRun(
@@ -80,54 +80,6 @@ describe('npmAdapter', () => {
8080
return RSVP.resolve();
8181
},
8282
},
83-
{
84-
command: 'npm --version',
85-
callback() {
86-
runCount++;
87-
return RSVP.resolve({ stdout: '5.7.1' });
88-
},
89-
},
90-
],
91-
{ allowPassthrough: false }
92-
);
93-
94-
let adapter = new NpmAdapter({
95-
cwd: tmpdir,
96-
run: stubbedRun,
97-
});
98-
99-
await adapter._install();
100-
expect(runCount).to.equal(2);
101-
});
102-
103-
it('runs npm prune and npm install with npm 4', async () => {
104-
writeJSONFile('package.json', fixturePackage);
105-
let runCount = 0;
106-
let stubbedRun = generateMockRun(
107-
[
108-
{
109-
command: 'npm install --no-shrinkwrap',
110-
callback(command, args, opts) {
111-
runCount++;
112-
expect(opts).to.have.property('cwd', tmpdir);
113-
return RSVP.resolve();
114-
},
115-
},
116-
{
117-
command: 'npm prune',
118-
callback(command, args, opts) {
119-
runCount++;
120-
expect(opts).to.have.property('cwd', tmpdir);
121-
return RSVP.resolve();
122-
},
123-
},
124-
{
125-
command: 'npm --version',
126-
callback() {
127-
runCount++;
128-
return RSVP.resolve({ stdout: '4.7.1' });
129-
},
130-
},
13183
],
13284
{ allowPassthrough: false }
13385
);
@@ -138,7 +90,7 @@ describe('npmAdapter', () => {
13890
});
13991

14092
await adapter._install();
141-
expect(runCount).to.equal(3, 'All three commands should run');
93+
expect(runCount).to.equal(1);
14294
});
14395

14496
it('uses managerOptions for npm commands', async () => {
@@ -153,13 +105,6 @@ describe('npmAdapter', () => {
153105
return RSVP.resolve();
154106
},
155107
},
156-
{
157-
command: 'npm --version',
158-
callback() {
159-
runCount++;
160-
return RSVP.resolve({ stdout: '5.7.1' });
161-
},
162-
},
163108
],
164109
{ allowPassthrough: false }
165110
);
@@ -171,7 +116,7 @@ describe('npmAdapter', () => {
171116
});
172117

173118
await adapter._install();
174-
expect(runCount).to.equal(2);
119+
expect(runCount).to.equal(1);
175120
});
176121

177122
it('uses buildManagerOptions for npm commands', async () => {
@@ -186,13 +131,6 @@ describe('npmAdapter', () => {
186131
return RSVP.resolve();
187132
},
188133
},
189-
{
190-
command: 'npm --version',
191-
callback() {
192-
runCount++;
193-
return RSVP.resolve({ stdout: '5.7.1' });
194-
},
195-
},
196134
],
197135
{ allowPassthrough: false }
198136
);
@@ -206,7 +144,7 @@ describe('npmAdapter', () => {
206144
});
207145

208146
await adapter._install();
209-
expect(runCount).to.equal(2, 'npm install should run with buildManagerOptions');
147+
expect(runCount).to.equal(1, 'npm install should run with buildManagerOptions');
210148
});
211149

212150
it('throws an error if buildManagerOptions does not return an array', async () => {
@@ -382,13 +320,6 @@ describe('npmAdapter', () => {
382320
return Promise.resolve();
383321
},
384322
},
385-
{
386-
command: 'npm --version',
387-
callback() {
388-
runCount++;
389-
return RSVP.resolve({ stdout: '10.0.0' });
390-
},
391-
},
392323
],
393324
{ allowPassthrough: false }
394325
);
@@ -400,7 +331,7 @@ describe('npmAdapter', () => {
400331

401332
await adapter._restoreOriginalDependencies();
402333

403-
expect(runCount).to.equal(2);
334+
expect(runCount).to.equal(1);
404335
});
405336
});
406337

0 commit comments

Comments
 (0)