Skip to content

Commit

Permalink
Merge pull request ember-cli#10161 from bertdeblock/remove-npm-versio…
Browse files Browse the repository at this point in the history
…n-checking

[ENHANCEMENT] Remove NPM version checking
  • Loading branch information
bertdeblock authored Feb 4, 2023
2 parents 1b70e49 + 72156c0 commit 9e7e3c2
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 44 deletions.
20 changes: 0 additions & 20 deletions lib/tasks/npm-task.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ class NpmTask extends Task {

// The command to run: can be 'install' or 'uninstall'
this.command = '';

this.versionConstraints = '3 || 4 || 5 || 6 || 7 || 8';
}

get packageManagerOutputName() {
Expand Down Expand Up @@ -115,24 +113,6 @@ class NpmTask extends Task {
let version = result.stdout;
logger.info('npm --version: %s', version);

let ok = semver.satisfies(version, this.versionConstraints);
if (!ok) {
logger.warn('npm --version is outside of version constraint: %s', this.versionConstraints);

let below = semver.ltr(version, this.versionConstraints);
if (below) {
throw new SilentError(
'Ember CLI is now using the global npm, but your npm version is outdated.\n' +
'Please update your global npm version by running: npm install -g npm'
);
}

this.ui.writeWarnLine(
'Ember CLI is using the global npm, but your npm version has not yet been ' +
'verified to work with the current Ember CLI release.'
);
}

return { name: 'npm', version };
} catch (error) {
logger.error('npm --version failed: %s', error);
Expand Down
24 changes: 0 additions & 24 deletions tests/unit/tasks/npm-task-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,6 @@ describe('NpmTask', function () {
expect(ui.errors).to.be.empty;
});

it('resolves with warning when a newer version is found', async function () {
td.when(task.npm(['--version'])).thenResolve({ stdout: '9.0.0' });

await task.checkNpmVersion();
expect(ui.output).to.contain('WARNING');
expect(ui.errors).to.be.empty;
});

it('rejects when an older version is found', async function () {
td.when(task.npm(['--version'])).thenResolve({ stdout: '2.9.9' });

await expect(task.checkNpmVersion()).to.be.rejectedWith(SilentError, /npm install -g npm/);
expect(ui.output).to.be.empty;
expect(ui.errors).to.be.empty;
});

it('rejects when npm is not found', async function () {
let error = new Error('npm not found');
error.code = 'ENOENT';
Expand All @@ -54,14 +38,6 @@ describe('NpmTask', function () {
expect(ui.errors).to.be.empty;
});

it('rejects when npm returns an unreadable version', async function () {
td.when(task.npm(['--version'])).thenResolve({ stdout: '5' });

await expect(task.checkNpmVersion()).to.be.rejectedWith(TypeError, /Invalid Version/);
expect(ui.output).to.be.empty;
expect(ui.errors).to.be.empty;
});

it('rejects when an unknown error is thrown', async function () {
td.when(task.npm(['--version'])).thenReject(new Error('foobar?'));

Expand Down

0 comments on commit 9e7e3c2

Please sign in to comment.