@nestjs/schematics
Version:
Nest - modern, fast, powerful node.js web framework (@schematics)
23 lines (22 loc) • 517 B
JavaScript
import { parse } from 'jsonc-parser';
export const NEST_CLI_CONFIG_FILES = [
'nest-cli.json',
'.nestcli.json',
'.nest-cli.json',
'nest.json',
];
export function findNestCliConfigPath(tree) {
return NEST_CLI_CONFIG_FILES.find((candidate) => tree.exists(candidate));
}
export function readJsonFile(tree, path) {
const buffer = tree.read(path);
if (!buffer) {
return null;
}
try {
return parse(buffer.toString('utf-8'));
}
catch {
return null;
}
}