feat: add chainAndMerge utility rule creator

pull/5222/head
Arman Ozak 5 years ago
parent f0146805fc
commit 722145cf07

@ -1,6 +1,8 @@
import {
apply,
chain,
forEach,
MergeStrategy,
mergeWith,
Rule,
SchematicContext,
@ -16,6 +18,14 @@ export function applyWithOverwrite(source: Source, rules: Rule[]): Rule {
};
}
export function chainAndMerge(rules: Rule[]) {
return (host: Tree) => async (tree: Tree, context: SchematicContext) =>
host.merge(
(await (chain(rules)(tree, context) as any).toPromise()) as Tree,
MergeStrategy.AllowDeleteConflict,
);
}
export function overwriteFileIfExists(tree: Tree): Rule {
return forEach(fileEntry => {
if (!tree.exists(fileEntry.path)) return fileEntry;

Loading…
Cancel
Save