@mihalcan/shallow-render-schematics
Version:
Add shallow-render to an Angular CLI project
13 lines (9 loc) • 391 B
text/typescript
import { Tree } from '@angular-devkit/schematics';
/** Gets the content of a specified file from a schematic tree. */
export function getFileContent(tree: Tree, filePath: string): string {
const contentBuffer = tree.read(filePath);
if (!contentBuffer) {
throw new Error(`Cannot read "${filePath}" because it does not exist.`);
}
return contentBuffer.toString();
}