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

Function parseOptions

server/bin/cli.ts:33–54  ·  view source on GitHub ↗
(path: string)

Source from the content-addressed store, hash-verified

31var args = <any>program;
32
33function parseOptions(path: string) {
34 if (!path) return;
35 if (!fs.existsSync(path)) return;
36
37 var content = fs.readFileSync(path).toString();
38
39 try {
40 var configs = JSON.parse(content);
41 return {
42 port: configs.port,
43 password: configs.password,
44 cipherAlgorithm: configs.method,
45 fork: configs.fork,
46 cluster: configs.cluster,
47 timeout: configs.timeout,
48 management: configs.management,
49 }
50 } catch(ex) {
51 console.warn('Configuration file error');
52 console.warn(ex.message);
53 }
54}
55
56var fileOptions = parseOptions(args.config) || {};
57if (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