Skip to content

Commit cae2209

Browse files
alan-agius4clydin
authored andcommitted
fix(@angular/cli): only show incompatible NPM error when NPM is used as package manager
1 parent 95a2a57 commit cae2209

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

packages/angular/cli/commands/add-impl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export class AddCommand extends SchematicCommand<AddCommandSchema> {
3939
}
4040

4141
async run(options: AddCommandSchema & Arguments) {
42-
ensureCompatibleNpm();
42+
await ensureCompatibleNpm(this.context.root);
4343

4444
if (!options.collection) {
4545
this.logger.fatal(

packages/angular/cli/commands/new-impl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export class NewCommand extends SchematicCommand<NewCommandSchema> {
2222
}
2323

2424
public async run(options: NewCommandSchema & Arguments) {
25-
ensureCompatibleNpm();
25+
await ensureCompatibleNpm(this.context.root);
2626

2727
// Register the version of the CLI in the registry.
2828
const packageJson = require('../package.json');

packages/angular/cli/commands/update-impl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ export class UpdateCommand extends Command<UpdateCommandSchema> {
267267

268268
// tslint:disable-next-line:no-big-function
269269
async run(options: UpdateCommandSchema & Arguments) {
270-
ensureCompatibleNpm();
270+
await ensureCompatibleNpm(this.context.root);
271271

272272
// Check if the current installed CLI version is older than the latest version.
273273
if (!disableVersionCheck && await this.checkCLILatestVersion(options.verbose, options.next)) {

packages/angular/cli/utilities/package-manager.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,11 @@ export async function getPackageManager(root: string): Promise<PackageManager> {
5858
/**
5959
* Checks if the npm version is version 6.x. If not, display a message and exit.
6060
*/
61-
export function ensureCompatibleNpm() {
61+
export async function ensureCompatibleNpm(root: string): Promise<void> {
62+
if ((await getPackageManager(root)) !== PackageManager.Npm) {
63+
return;
64+
}
65+
6266
try {
6367
const version = execSync('npm --version', {encoding: 'utf8', stdio: 'pipe'}).trim();
6468
const major = Number(version.match(/^(\d+)\./)?.[1]);

0 commit comments

Comments
 (0)