Skip to content

Commit

Permalink
fix(schematics): fix component option
Browse files Browse the repository at this point in the history
  • Loading branch information
Domainv committed Dec 5, 2018
1 parent 3a17cc3 commit cba4b35
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions schematics/src/ng-add/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,14 @@ const datePickerStylePath = `./node_modules/ngx-bootstrap/datepicker/bs-datepic
/* tslint:disable-next-line: no-default-export */
export default function (options: Schema): Rule {
return chain([
addStyles(options),
addPackageJsonDependencies(),
installPackageJsonDependencies(),
options.component ? addModuleOfComponent(options.project, options.component) : noop()
options.component
? addStyles(options, _insertBootstrapStyle)
: addStyles(options, _insertCommonStyles),
options.component
? addModuleOfComponent(options.project, options.component)
: noop()
]);
}

Expand Down Expand Up @@ -97,7 +101,7 @@ function addPackageJsonDependencies(): Rule {
};
}

export function addStyles(options: Schema): (host: Tree) => Tree {
export function addStyles(options: Schema, insertStyle: Function): (host: Tree) => Tree {
return function (host: Tree): Tree {
const workspace = getWorkspace(host);
const project = getProjectFromWorkspace(workspace, options.project);
Expand All @@ -108,7 +112,12 @@ export function addStyles(options: Schema): (host: Tree) => Tree {
};
}

function insertStyle(project: WorkspaceProject, host: Tree, workspace: WorkspaceSchema) {
function _insertBootstrapStyle(project: WorkspaceProject, host: Tree, workspace: WorkspaceSchema) {
addStyleToTarget(project, 'build', host, bootstrapStylePath, workspace);
addStyleToTarget(project, 'test', host, bootstrapStylePath, workspace);
}

function _insertCommonStyles(project: WorkspaceProject, host: Tree, workspace: WorkspaceSchema) {
addStyleToTarget(project, 'build', host, datePickerStylePath, workspace);
addStyleToTarget(project, 'test', host, datePickerStylePath, workspace);
addStyleToTarget(project, 'build', host, bootstrapStylePath, workspace);
Expand Down

0 comments on commit cba4b35

Please sign in to comment.