Skip to content

Commit

Permalink
refactor(@schematics/angular): remove redundant branchAndMerge rules
Browse files Browse the repository at this point in the history
  • Loading branch information
clydin authored and alexeagle committed Feb 13, 2019
1 parent 26f3475 commit d941c2b
Show file tree
Hide file tree
Showing 18 changed files with 18 additions and 42 deletions.
3 changes: 1 addition & 2 deletions packages/schematics/angular/class/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
Tree,
apply,
applyTemplates,
branchAndMerge,
chain,
filter,
mergeWith,
Expand Down Expand Up @@ -57,7 +56,7 @@ export default function (options: ClassOptions): Rule {
]);

return chain([
branchAndMerge(mergeWith(templateSource)),
mergeWith(templateSource),
options.lintFix ? applyLintFix(options.path) : noop(),
]);
};
Expand Down
7 changes: 2 additions & 5 deletions packages/schematics/angular/component/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
Tree,
apply,
applyTemplates,
branchAndMerge,
chain,
filter,
mergeWith,
Expand Down Expand Up @@ -167,10 +166,8 @@ export default function (options: ComponentOptions): Rule {
]);

return chain([
branchAndMerge(chain([
addDeclarationToNgModule(options),
mergeWith(templateSource),
])),
addDeclarationToNgModule(options),
mergeWith(templateSource),
options.lintFix ? applyLintFix(options.path) : noop(),
]);
};
Expand Down
7 changes: 2 additions & 5 deletions packages/schematics/angular/directive/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
Tree,
apply,
applyTemplates,
branchAndMerge,
chain,
filter,
mergeWith,
Expand Down Expand Up @@ -135,10 +134,8 @@ export default function (options: DirectiveOptions): Rule {
]);

return chain([
branchAndMerge(chain([
addDeclarationToNgModule(options),
mergeWith(templateSource),
])),
addDeclarationToNgModule(options),
mergeWith(templateSource),
options.lintFix ? applyLintFix(options.path) : noop(),
]);
};
Expand Down
5 changes: 1 addition & 4 deletions packages/schematics/angular/enum/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
Tree,
apply,
applyTemplates,
branchAndMerge,
chain,
mergeWith,
move,
Expand Down Expand Up @@ -50,9 +49,7 @@ export default function (options: EnumOptions): Rule {
]);

return chain([
branchAndMerge(chain([
mergeWith(templateSource),
])),
mergeWith(templateSource),
options.lintFix ? applyLintFix(options.path) : noop(),
]);
};
Expand Down
5 changes: 1 addition & 4 deletions packages/schematics/angular/guard/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
Tree,
apply,
applyTemplates,
branchAndMerge,
chain,
filter,
mergeWith,
Expand Down Expand Up @@ -70,9 +69,7 @@ export default function (options: GuardOptions): Rule {
]);

return chain([
branchAndMerge(chain([
mergeWith(templateSource),
])),
mergeWith(templateSource),
options.lintFix ? applyLintFix(options.path) : noop(),
]);
};
Expand Down
5 changes: 1 addition & 4 deletions packages/schematics/angular/interface/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
Tree,
apply,
applyTemplates,
branchAndMerge,
chain,
mergeWith,
move,
Expand Down Expand Up @@ -52,9 +51,7 @@ export default function (options: InterfaceOptions): Rule {
]);

return chain([
branchAndMerge(chain([
mergeWith(templateSource),
])),
mergeWith(templateSource),
options.lintFix ? applyLintFix(options.path) : noop(),
]);
};
Expand Down
8 changes: 3 additions & 5 deletions packages/schematics/angular/library/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import {
Tree,
apply,
applyTemplates,
branchAndMerge,
chain,
mergeWith,
move,
noop,
schematic,
url,
Expand Down Expand Up @@ -215,13 +215,11 @@ export default function (options: LibraryOptions): Rule {
angularLatestVersion: latestVersions.Angular.replace('~', '').replace('^', ''),
folderName,
}),
// TODO: Moving inside `branchAndMerge` should work but is bugged right now.
// The __projectRoot__ is being used meanwhile.
// move(projectRoot),
move(projectRoot),
]);

return chain([
branchAndMerge(mergeWith(templateSource)),
mergeWith(templateSource),
addAppToWorkspaceFile(options, workspace, projectRoot, projectName),
options.skipPackageJson ? noop() : addDependenciesToPackageJson(),
options.skipTsConfig ? noop() : updateTsConfig(packageName, distRoot),
Expand Down
7 changes: 2 additions & 5 deletions packages/schematics/angular/module/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
Tree,
apply,
applyTemplates,
branchAndMerge,
chain,
filter,
mergeWith,
Expand Down Expand Up @@ -99,10 +98,8 @@ export default function (options: ModuleOptions): Rule {
]);

return chain([
branchAndMerge(chain([
addDeclarationToNgModule(options),
mergeWith(templateSource),
])),
addDeclarationToNgModule(options),
mergeWith(templateSource),
options.lintFix ? applyLintFix(options.path) : noop(),
]);
};
Expand Down
13 changes: 5 additions & 8 deletions packages/schematics/angular/pipe/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
Tree,
apply,
applyTemplates,
branchAndMerge,
chain,
filter,
mergeWith,
Expand Down Expand Up @@ -115,12 +114,10 @@ export default function (options: PipeOptions): Rule {
move(parsedPath.path),
]);

return branchAndMerge(
chain([
addDeclarationToNgModule(options),
mergeWith(templateSource),
options.lintFix ? applyLintFix(options.path) : noop(),
]),
);
return chain([
addDeclarationToNgModule(options),
mergeWith(templateSource),
options.lintFix ? applyLintFix(options.path) : noop(),
]);
};
}

0 comments on commit d941c2b

Please sign in to comment.