MCPcopy Create free account
hub / github.com/UnsignedInt8/LightSword / parseFile

Function parseFile

client/bin/cli.ts:31–43  ·  view source on GitHub ↗
(path: string)

Source from the content-addressed store, hash-verified

29var args = <any>program;
30
31function parseFile(path: string) {
32 if (!path) return;
33 if (!fs.existsSync(path)) return;
34
35 var content = fs.readFileSync(path).toString();
36
37 try {
38 return JSON.parse(content);
39 } catch(ex) {
40 console.warn('Configuration file error');
41 console.warn(ex.message);
42 }
43}
44
45var fileOptions = parseFile(args.config) || {};
46if (fileOptions) Object.getOwnPropertyNames(fileOptions).forEach(n => args[n] = args[n] === undefined ? fileOptions[n] : args[n]);

Callers 1

cli.tsFile · 0.85

Calls 3

toStringMethod · 0.80
parseMethod · 0.80
warnMethod · 0.80

Tested by

no test coverage detected