mirror of https://github.com/abpframework/abp
parent
ab5a5a46b4
commit
5358d5b916
@ -1,6 +1,7 @@
|
||||
export * from './angular';
|
||||
export * from './ast';
|
||||
export * from './common';
|
||||
export * from './rule';
|
||||
export * from './source';
|
||||
export * from './text';
|
||||
export * from './workspace';
|
||||
|
@ -0,0 +1,26 @@
|
||||
import {
|
||||
apply,
|
||||
forEach,
|
||||
mergeWith,
|
||||
Rule,
|
||||
SchematicContext,
|
||||
Source,
|
||||
Tree,
|
||||
} from '@angular-devkit/schematics';
|
||||
|
||||
export function applyWithOverwrite(source: Source, rules: Rule[]): Rule {
|
||||
return (tree: Tree, _context: SchematicContext) => {
|
||||
const rule = mergeWith(apply(source, [...rules, overwriteFileIfExists(tree)]));
|
||||
|
||||
return rule(tree, _context);
|
||||
};
|
||||
}
|
||||
|
||||
export function overwriteFileIfExists(tree: Tree): Rule {
|
||||
return forEach(fileEntry => {
|
||||
if (!tree.exists(fileEntry.path)) return fileEntry;
|
||||
|
||||
tree.overwrite(fileEntry.path, fileEntry.content);
|
||||
return null;
|
||||
});
|
||||
}
|
Loading…
Reference in new issue