Skip to content
Permalink
Browse files

feat(schematics): use the project's style extension (#3930)

  • Loading branch information...
hsuanxyz authored and wendzhue committed Aug 9, 2019
1 parent ac866ce commit 84b0355dc9070a7251ff524553f4101dc5314266
Showing with 18 additions and 6 deletions.
  1. +7 −1 schematics/ng-add/index.ts
  2. +2 −5 schematics/ng-generate/side-menu/index.ts
  3. +9 −0 schematics/utils/project-style.ts
@@ -1,6 +1,9 @@
import { Rule, SchematicContext, Tree } from '@angular-devkit/schematics';
import { NodePackageInstallTask, RunSchematicTask } from '@angular-devkit/schematics/tasks';
import { getProjectFromWorkspace } from '@angular/cdk/schematics';
import { getWorkspace } from '@schematics/angular/utility/config';
import { addPackageToPackageJson } from '../utils/package-config';
import { getProjectStyle } from '../utils/project-style';
import { hammerjsVersion, zorroVersion } from '../utils/version-names';
import { Schema } from './schema';

@@ -18,7 +21,10 @@ export default function(options: Schema): Rule {
context.addTask(new RunSchematicTask('ng-add-setup-project', options), [installTaskId]);

if (options.template) {
context.addTask(new RunSchematicTask(options.template, options));
const workspace = getWorkspace(host);
const project = getProjectFromWorkspace(workspace, options.project);
const style = getProjectStyle(project);
context.addTask(new RunSchematicTask(options.template, {...options, style: style}));
}

};
@@ -13,7 +13,6 @@ import {
Tree
} from '@angular-devkit/schematics';
import { getProjectFromWorkspace } from '@angular/cdk/schematics';
import { Style } from '@schematics/angular/application/schema';
import { getWorkspace } from '@schematics/angular/utility/config';
import { addModule } from '../../utils/root-module';

@@ -24,16 +23,14 @@ export default function(options: Schema): Rule {
const workspace = getWorkspace(host);
const project = getProjectFromWorkspace(workspace, options.project);
const prefix = options.prefix || project.prefix;
const style = options.style || Style.Css;
return chain([
mergeWith(
apply(
url('./files/src'), [
applyTemplates({
prefix,
style,
...strings,
...options
...options,
prefix
}),
move(project.sourceRoot as string),
forEach((fileEntry: FileEntry) => {
@@ -0,0 +1,9 @@
import { WorkspaceProject } from '@angular-devkit/core/src/experimental/workspace';
import { getProjectStyleFile } from '@angular/cdk/schematics';
import { Style } from '@schematics/angular/application/schema';

export function getProjectStyle(project: WorkspaceProject): Style {
const stylesPath = getProjectStyleFile(project);
const style = stylesPath ? stylesPath.split('.').pop() : Style.Css;
return style as Style;
}

0 comments on commit 84b0355

Please sign in to comment.
You can’t perform that action at this time.