@serpent/common-cli
Version:
通用的 cli 相关的函数
21 lines (18 loc) • 520 B
JavaScript
import fs from 'fs';
import { h as existsFile } from './context-96dcd180.mjs';
/**
* 获取 json 文件的内容,如果没有或者解析 json 失败则返回 undefined
*/
function tryReadJsonFile(absJsonPath) {
if (existsFile(absJsonPath)) {
try {
return readJsonFile(absJsonPath);
}
catch (e) { }
}
return;
}
function readJsonFile(absJsonPath) {
return JSON.parse(fs.readFileSync(absJsonPath).toString());
}
export { readJsonFile as r, tryReadJsonFile as t };