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> {
38
38
}
39
39
40
40
async run ( options : AddCommandSchema & Arguments ) {
41
- ensureCompatibleNpm ( ) ;
41
+ await ensureCompatibleNpm ( this . context . root ) ;
42
42
43
43
if ( ! options . collection ) {
44
44
this . logger . fatal (
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ export class NewCommand extends SchematicCommand<NewCommandSchema> {
24
24
}
25
25
26
26
public async run ( options : NewCommandSchema & Arguments ) {
27
- ensureCompatibleNpm ( ) ;
27
+ await ensureCompatibleNpm ( this . context . root ) ;
28
28
29
29
// Register the version of the CLI in the registry.
30
30
const packageJson = require ( '../package.json' ) ;
Original file line number Diff line number Diff line change @@ -254,7 +254,7 @@ export class UpdateCommand extends Command<UpdateCommandSchema> {
254
254
255
255
// tslint:disable-next-line:no-big-function
256
256
async run ( options : UpdateCommandSchema & Arguments ) {
257
- ensureCompatibleNpm ( ) ;
257
+ await ensureCompatibleNpm ( this . context . root ) ;
258
258
259
259
// Check if the @angular -devkit/schematics package can be resolved from the workspace root
260
260
// 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> {
58
58
/**
59
59
* Checks if the npm version is version 6.x. If not, display a message and exit.
60
60
*/
61
- export function ensureCompatibleNpm ( ) {
61
+ export async function ensureCompatibleNpm ( root : string ) : Promise < void > {
62
+ if ( ( await getPackageManager ( root ) ) !== PackageManager . Npm ) {
63
+ return ;
64
+ }
65
+
62
66
try {
63
67
const version = execSync ( 'npm --version' , { encoding : 'utf8' , stdio : 'pipe' } ) . trim ( ) ;
64
68
const major = Number ( version . match ( / ^ ( \d + ) \. / ) ?. [ 1 ] ) ;
You can’t perform that action at this time.
0 commit comments