MCPcopy Index your code
hub / github.com/angular/angular-cli / updateJsonFile

Function updateJsonFile

tests/e2e/utils/project.ts:12–20  ·  view source on GitHub ↗
(filePath: string, fn: (json: any) => any | void)

Source from the content-addressed store, hash-verified

10import { join } from 'node:path';
11
12export function updateJsonFile(filePath: string, fn: (json: any) => any | void) {
13 return readFile(filePath).then((tsConfigJson) => {
14 // Remove single and multiline comments
15 const tsConfig = JSON.parse(tsConfigJson.replace(/\/\*\s(.|\n|\r)*\s\*\/|\/\/.*/g, '')) as any;
16 const result = fn(tsConfig) || tsConfig;
17
18 return writeFile(filePath, JSON.stringify(result, null, 2));
19 });
20}
21
22export function updateTsConfig(fn: (json: any) => any | void) {
23 return updateJsonFile('tsconfig.json', fn);

Calls 3

readFileFunction · 0.90
writeFileFunction · 0.90
fnFunction · 0.85

Tested by

no test coverage detected