mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-18 11:44:05 +08:00
Update NPM 7 behavior based on https://github.com/angular/angular-cli/issues/19957#issuecomment-775407654
42 lines
1.3 KiB
TypeScript
42 lines
1.3 KiB
TypeScript
/**
|
|
* @license
|
|
* Copyright Google Inc. All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
* found in the LICENSE file at https://angular.io/license
|
|
*/
|
|
import { Arguments } from '../models/interface';
|
|
import { SchematicCommand } from '../models/schematic-command';
|
|
import { ensureCompatibleNpm } from '../utilities/package-manager';
|
|
import { Schema as NewCommandSchema } from './new';
|
|
|
|
|
|
export class NewCommand extends SchematicCommand<NewCommandSchema> {
|
|
public readonly allowMissingWorkspace = true;
|
|
schematicName = 'ng-new';
|
|
|
|
async initialize(options: NewCommandSchema & Arguments) {
|
|
this.collectionName = options.collection || await this.getDefaultSchematicCollection();
|
|
|
|
return super.initialize(options);
|
|
}
|
|
|
|
public async run(options: NewCommandSchema & Arguments) {
|
|
// Register the version of the CLI in the registry.
|
|
const packageJson = require('../package.json');
|
|
const version = packageJson.version;
|
|
|
|
this._workflow.registry.addSmartDefaultProvider('ng-cli-version', () => version);
|
|
|
|
return this.runSchematic({
|
|
collectionName: this.collectionName,
|
|
schematicName: this.schematicName,
|
|
schematicOptions: options['--'] || [],
|
|
debug: !!options.debug,
|
|
dryRun: !!options.dryRun,
|
|
force: !!options.force,
|
|
});
|
|
}
|
|
|
|
}
|