登录优化:gate可变为短链接
This commit is contained in:
@@ -390,6 +390,23 @@ export function deepCopy(obj) {
|
||||
return target;
|
||||
};
|
||||
|
||||
export function readFile(addr: string) {
|
||||
return fs.readFileSync(path.resolve(__dirname, `${addr}`)).toString('utf8').replace(/^\uFEFF/, '');
|
||||
}
|
||||
|
||||
export function writeFile(addr: string, data: string) {
|
||||
return fs.writeFileSync(addr, data);
|
||||
}
|
||||
|
||||
export function readFileAndParseJson(path: string) {
|
||||
try {
|
||||
let readResult = readFile(path);
|
||||
return JSON.parse(readResult);
|
||||
} catch(e) {
|
||||
throw new Error(`connectors.json 格式错误:${e.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
export function readJsonFile(fileName: string) {
|
||||
const folder = 'jsons';
|
||||
return fs.readFileSync(path.resolve(__dirname, `../resource/${folder}/${fileName}.json`)).toString('utf8').replace(/^\uFEFF/, '');
|
||||
|
||||
Reference in New Issue
Block a user