Skip to content

Commit

Permalink
fix(@schematics/angular): set cortrect file extention in config when …
Browse files Browse the repository at this point in the history
…using preprocessors (#13552)

Fixes #13550
  • Loading branch information
alan-agius4 authored and vikerman committed Feb 6, 2019
1 parent fb072cf commit f6a606d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
6 changes: 4 additions & 2 deletions packages/schematics/angular/application/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ function addAppToWorkspaceFile(options: ApplicationOptions, workspace: Workspace
});
}

const styleExt = styleToFileExtention(options.style);

const project: WorkspaceProject = {
root: projectRoot,
sourceRoot: join(normalize(projectRoot), 'src'),
Expand All @@ -205,7 +207,7 @@ function addAppToWorkspaceFile(options: ApplicationOptions, workspace: Workspace
join(normalize(projectRoot), 'src', 'assets'),
],
styles: [
`${projectRoot}src/styles.${options.style}`,
`${projectRoot}src/styles.${styleExt}`,
],
scripts: [],
es5BrowserSupport: true,
Expand Down Expand Up @@ -258,7 +260,7 @@ function addAppToWorkspaceFile(options: ApplicationOptions, workspace: Workspace
tsConfig: `${rootFilesRoot}tsconfig.spec.json`,
karmaConfig: `${rootFilesRoot}karma.conf.js`,
styles: [
`${projectRoot}src/styles.${options.style}`,
`${projectRoot}src/styles.${styleExt}`,
],
scripts: [],
assets: [
Expand Down
18 changes: 17 additions & 1 deletion packages/schematics/angular/application/index_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { SchematicTestRunner, UnitTestTree } from '@angular-devkit/schematics/te
import { latestVersions } from '../utility/latest-versions';
import { getFileContent } from '../utility/test';
import { Schema as WorkspaceOptions } from '../workspace/schema';
import { Schema as ApplicationOptions } from './schema';
import { Schema as ApplicationOptions, Style } from './schema';

// tslint:disable:max-line-length
describe('Application Schematic', () => {
Expand Down Expand Up @@ -275,6 +275,22 @@ describe('Application Schematic', () => {
]);
});

it('should set values in angular.json correctly when using a style preprocessor', () => {
const options = { ...defaultOptions, projectRoot: '', style: Style.Sass };
const tree = schematicRunner.runSchematic('application', options, workspaceTree);
const config = JSON.parse(tree.readContent('/angular.json'));
const prj = config.projects.foo;
const buildOpt = prj.architect.build.options;
expect(buildOpt.styles).toEqual([
'src/styles.scss',
]);
const testOpt = prj.architect.test.options;
expect(testOpt.styles).toEqual([
'src/styles.scss',
]);
expect(tree.exists('src/styles.scss')).toBe(true);
});

it('should set the relative tsconfig paths', () => {
const options = { ...defaultOptions, projectRoot: '' };

Expand Down

0 comments on commit f6a606d

Please sign in to comment.