mirror of https://github.com/abpframework/abp.git
8 changed files with 87 additions and 22 deletions
@ -1,6 +1,7 @@ |
|||||
export * from './angular'; |
export * from './angular'; |
||||
export * from './ast'; |
export * from './ast'; |
||||
export * from './common'; |
export * from './common'; |
||||
|
export * from './rule'; |
||||
export * from './source'; |
export * from './source'; |
||||
export * from './text'; |
export * from './text'; |
||||
export * from './workspace'; |
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