File tree Expand file tree Collapse file tree 4 files changed +8
-4
lines changed Expand file tree Collapse file tree 4 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ export class AddCommand extends SchematicCommand<AddCommandSchema> {
3838 }
3939
4040 async run ( options : AddCommandSchema & Arguments ) {
41- ensureCompatibleNpm ( ) ;
41+ await ensureCompatibleNpm ( this . context . root ) ;
4242
4343 if ( ! options . collection ) {
4444 this . logger . fatal (
Original file line number Diff line number Diff 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' ) ;
Original file line number Diff line number Diff line change @@ -256,7 +256,7 @@ export class UpdateCommand extends Command<UpdateCommandSchema> {
256256
257257 // tslint:disable-next-line:no-big-function
258258 async run ( options : UpdateCommandSchema & Arguments ) {
259- ensureCompatibleNpm ( ) ;
259+ await ensureCompatibleNpm ( this . context . root ) ;
260260
261261 // Check if the @angular -devkit/schematics package can be resolved from the workspace root
262262 // This works around issues with packages containing migrations that cannot directly depend on the package
Original file line number Diff line number Diff 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 ] ) ;
You can’t perform that action at this time.
0 commit comments