12345678910111213141516 |
- 'use strict';
- const fs = require('fs');
- const util = require('util');
- const readFile = util.promisify(fs.readFile);
- module.exports = {
- async readConfig(path) {
- try {
- const data = await readFile(path);
- return JSON.parse(data);
- } catch (error) {
- const body = { errcode: -1000, errmsg: '读取配置文件失败', error };
- throw new Error(JSON.stringify(body));
- }
- },
- };
|