fix 无法修改配置文件
This commit is contained in:
@@ -16,16 +16,16 @@ function getConfig() {
|
||||
|
||||
/**
|
||||
* 保存配置文件
|
||||
* @param string
|
||||
* @param config{String}
|
||||
* @return {boolean}
|
||||
*/
|
||||
function setConfig(string) {
|
||||
console.info(string)
|
||||
fs.writeFileSync("config.json", JSON.parse(string));
|
||||
return getConfig() === string;
|
||||
function setConfig(config) {
|
||||
const data = JSON.stringify(config, null, 2)
|
||||
fs.writeFileSync("config.json", data);
|
||||
return JSON.stringify(getConfig(), null, 2) === data
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getConfig,
|
||||
setConfig
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user