MCPcopy
hub / github.com/CopyTranslator/CopyTranslator / load

Method load

src/common/configParser.ts:132–151  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

130 }
131
132 load(): boolean {
133 let status = true;
134 try {
135 const values = JSON.parse(readFileSync(this.file) as any);
136 if (!values["version"] || !compatible(values["version"])) {
137 throw "version incompatible, configs will be reset"; //大版本冲突
138 }
139 if (isLower(values["version"], version)) {
140 //升级到新版本的也认为是新用户
141 values["isNewUser"] = true;
142 }
143 this.loadFromConfig(values);
144 } catch (e) {
145 console.log(e);
146 this.restoreDefault();
147 status = false;
148 }
149 this.save();
150 return status;
151 }
152
153 loadFromConfig(values: Config) {
154 const config: Config = {};

Callers 1

constructorMethod · 0.80

Calls 5

loadFromConfigMethod · 0.95
restoreDefaultMethod · 0.95
saveMethod · 0.95
compatibleFunction · 0.90
isLowerFunction · 0.90

Tested by

no test coverage detected