From e51c468772445ddfbeceb32c14b6f8ab22d7fff0 Mon Sep 17 00:00:00 2001 From: Cyrille Tuzi Date: Tue, 10 Apr 2018 18:21:03 +0200 Subject: [PATCH] feat(@schematics/angular): save ng new options as defaults --- .../schematics/angular/application/index.ts | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/packages/schematics/angular/application/index.ts b/packages/schematics/angular/application/index.ts index 6bf876884a..c14d7fcabe 100644 --- a/packages/schematics/angular/application/index.ts +++ b/packages/schematics/angular/application/index.ts @@ -5,7 +5,7 @@ * 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 { normalize, relative, strings, tags } from '@angular-devkit/core'; +import { JsonObject, normalize, relative, strings, tags } from '@angular-devkit/core'; import { experimental } from '@angular-devkit/core'; import { MergeStrategy, @@ -223,6 +223,35 @@ function addAppToWorkspaceFile(options: ApplicationOptions, workspace: Workspace // } workspace.projects[options.name] = project; + + const schematics: JsonObject = {}; + + if (options.inlineTemplate === true + || options.inlineStyle === true + || options.style !== undefined) { + schematics['@schematics/angular:component'] = {}; + if (options.inlineTemplate === true) { + (schematics['@schematics/angular:component'] as JsonObject).inlineTemplate = true; + } + if (options.inlineStyle === true) { + (schematics['@schematics/angular:component'] as JsonObject).inlineStyle = true; + } + if (options.style !== undefined) { + (schematics['@schematics/angular:component'] as JsonObject).styleext = options.style; + } + } + + if (options.skipTests === true) { + ['class', 'component', 'directive', 'guard', 'module', 'pipe', 'service'].forEach((type) => { + if (!(`@schematics/angular:${type}` in schematics)) { + schematics[`@schematics/angular:${type}`] = {}; + } + (schematics[`@schematics/angular:${type}`] as JsonObject).spec = false; + }); + } + + workspace.schematics = schematics; + host.overwrite(getWorkspacePath(host), JSON.stringify(workspace, null, 2)); }; }