diff --git a/packages/schematics/angular/application/index.ts b/packages/schematics/angular/application/index.ts index 213c9f20de77..3de361632581 100644 --- a/packages/schematics/angular/application/index.ts +++ b/packages/schematics/angular/application/index.ts @@ -22,6 +22,7 @@ import { template, url, } from '@angular-devkit/schematics'; +import { NodePackageInstallTask } from '@angular-devkit/schematics/tasks'; import { Schema as E2eOptions } from '../e2e/schema'; import { addProjectToWorkspace, @@ -63,8 +64,8 @@ import { Schema as ApplicationOptions } from './schema'; // ); // } -function addDependenciesToPackageJson() { - return (host: Tree) => { +function addDependenciesToPackageJson(options: ApplicationOptions) { + return (host: Tree, context: SchematicContext) => { [ { type: NodeDependencyType.Dev, @@ -83,6 +84,10 @@ function addDependenciesToPackageJson() { }, ].forEach(dependency => addPackageJsonDependency(host, dependency)); + if (!options.skipInstall) { + context.addTask(new NodePackageInstallTask()); + } + return host; }; } @@ -299,7 +304,6 @@ export default function (options: ApplicationOptions): Rule { return chain([ addAppToWorkspaceFile(options, workspace), - options.skipPackageJson ? noop() : addDependenciesToPackageJson(), mergeWith( apply(url('./files/src'), [ options.minimal ? filter(minimalPathFilter) : noop(), @@ -369,6 +373,7 @@ export default function (options: ApplicationOptions): Rule { move(sourceDir), ]), MergeStrategy.Overwrite), schematic('e2e', e2eOptions), + options.skipPackageJson ? noop() : addDependenciesToPackageJson(options), ]); }; } diff --git a/packages/schematics/angular/application/schema.json b/packages/schematics/angular/application/schema.json index 86d71341402c..0a6ab8ce7742 100644 --- a/packages/schematics/angular/application/schema.json +++ b/packages/schematics/angular/application/schema.json @@ -72,6 +72,11 @@ "description": "Create a barebones project without any testing frameworks", "type": "boolean", "default": false + }, + "skipInstall": { + "description": "Skip installing dependency packages.", + "type": "boolean", + "default": false } }, "required": [ diff --git a/packages/schematics/angular/ng-new/index.ts b/packages/schematics/angular/ng-new/index.ts index 7ce9e5e8f2a7..e71a83e5a917 100644 --- a/packages/schematics/angular/ng-new/index.ts +++ b/packages/schematics/angular/ng-new/index.ts @@ -55,6 +55,8 @@ export default function (options: NgNewOptions): Rule { style: options.style, skipTests: options.skipTests, skipPackageJson: false, + // always 'skipInstall' here, so that we do it after the move + skipInstall: true, }; return chain([