diff --git a/npm/ng-packs/packages/schematics/src/utils/file.ts b/npm/ng-packs/packages/schematics/src/utils/file.ts new file mode 100644 index 0000000000..cbfa9afcd2 --- /dev/null +++ b/npm/ng-packs/packages/schematics/src/utils/file.ts @@ -0,0 +1,8 @@ +import { Tree } from '@angular-devkit/schematics'; + +export function createFileSaver(tree: Tree) { + return (filePath: string, fileContent: string) => + tree.exists(filePath) + ? tree.overwrite(filePath, fileContent) + : tree.create(filePath, fileContent); +} diff --git a/npm/ng-packs/packages/schematics/src/utils/index.ts b/npm/ng-packs/packages/schematics/src/utils/index.ts index 304c2294b0..ea6bbad964 100644 --- a/npm/ng-packs/packages/schematics/src/utils/index.ts +++ b/npm/ng-packs/packages/schematics/src/utils/index.ts @@ -3,6 +3,7 @@ export * from './api'; export * from './ast'; export * from './common'; export * from './enum'; +export * from './file'; export * from './import'; export * from './model'; export * from './namespace';