From 953c5909dc214776eab9918e6a9e9dc45289eb57 Mon Sep 17 00:00:00 2001 From: Mike Brocchi Date: Tue, 22 Aug 2017 18:14:21 -0400 Subject: [PATCH] fix(@angular/cli): New project now respect default styleExt (#7430) Fixes #5599 --- packages/@angular/cli/tasks/init.ts | 4 ++++ tests/e2e/tests/commands/new/new-style.ts | 14 ++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 tests/e2e/tests/commands/new/new-style.ts diff --git a/packages/@angular/cli/tasks/init.ts b/packages/@angular/cli/tasks/init.ts index 984ccc8b2bc8..dd36103417c0 100644 --- a/packages/@angular/cli/tasks/init.ts +++ b/packages/@angular/cli/tasks/init.ts @@ -51,6 +51,10 @@ export default Task.extend({ const project = this.project; const packageName = commandOptions.name !== '.' && commandOptions.name || project.name(); + if (commandOptions.style === undefined) { + commandOptions.style = CliConfig.fromGlobal().get('defaults.styleExt'); + } + if (!packageName) { const message = 'The `ng ' + this.name + '` command requires a ' + 'package.json in current folder with name attribute or a specified name via arguments. ' + diff --git a/tests/e2e/tests/commands/new/new-style.ts b/tests/e2e/tests/commands/new/new-style.ts new file mode 100644 index 000000000000..882bab3a88e5 --- /dev/null +++ b/tests/e2e/tests/commands/new/new-style.ts @@ -0,0 +1,14 @@ +import {ng} from '../../../utils/process'; +import {createProject} from '../../../utils/project'; +import {expectFileToExist} from '../../../utils/fs'; + + +export default function() { + return Promise.resolve() + .then(() => ng('set', 'defaults.styleExt', 'scss', '--global')) + .then(() => createProject('style-project')) + .then(() => expectFileToExist('src/app/app.component.scss')) + + // Try to run the unit tests. + .then(() => ng('test', '--single-run')); +}