(path: string)
| 29 | var args = <any>program; |
| 30 | |
| 31 | function 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 | |
| 45 | var fileOptions = parseFile(args.config) || {}; |
| 46 | if (fileOptions) Object.getOwnPropertyNames(fileOptions).forEach(n => args[n] = args[n] === undefined ? fileOptions[n] : args[n]); |