Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | 29x 29x 163x 163x 15x 148x 148x 3x | import { SchematicsException, Tree } from '@angular-devkit/schematics';
export function readJsonFile<T>(tree: Tree, filePath: string): T {
const buffer = tree.read(filePath);
if (buffer === null) {
throw new SchematicsException(`Could not read ${filePath}`);
}
try {
return JSON.parse(buffer.toString());
} catch (error) {
throw new SchematicsException(`Invalid ${filePath}`);
}
}
|