mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-17 11:03:53 +08:00
26 lines
710 B
TypeScript
26 lines
710 B
TypeScript
import {readFile, writeFile} from './fs';
|
|
import {execAndWaitForOutputToMatch} from './process';
|
|
|
|
const tsConfigPath = 'src/tsconfig.json';
|
|
|
|
|
|
export function updateJsonFile(filePath: string, fn: (json: any) => any | void) {
|
|
return readFile(filePath)
|
|
.then(tsConfigJson => {
|
|
const tsConfig = JSON.parse(tsConfigJson);
|
|
const result = fn(tsConfig) || tsConfig;
|
|
|
|
return writeFile(filePath, JSON.stringify(result, null, 2));
|
|
});
|
|
}
|
|
|
|
|
|
export function updateTsConfig(fn: (json: any) => any | void) {
|
|
return updateJsonFile(tsConfigPath, fn);
|
|
}
|
|
|
|
|
|
export function ngServe(...args: string[]) {
|
|
return execAndWaitForOutputToMatch('ng', ['serve', ...args], /webpack: bundle is now VALID/);
|
|
}
|