1 | #!/usr/bin/env node
|
2 |
|
3 | var fs = require('fs'),
|
4 | path = require('path'),
|
5 | cwd = process.cwd(),
|
6 | argv = require('yargs').argv;
|
7 |
|
8 | var configFileName = path.resolve(cwd, argv.config || argv._[0] || 'watchalive.json')
|
9 |
|
10 | var options = {}
|
11 |
|
12 | if (fs.existsSync(configFileName)){
|
13 | try {
|
14 | console.log('Reading configuration file', configFileName)
|
15 | var fileConfig = JSON.parse(fs.readFileSync(configFileName))
|
16 | options = fileConfig
|
17 | } catch(e){
|
18 | console.log('Could parse watchalive configuration file', e)
|
19 | }
|
20 | }
|
21 |
|
22 | function takeParamFromArgs(param){
|
23 | options[param] = argv[param] || argv[param[0]] || options[param]
|
24 | }
|
25 |
|
26 | ;['base', 'port'].forEach(takeParamFromArgs)
|
27 |
|
28 | var App = require('./lib/app.js')
|
29 |
|
30 | var app = new App(options)
|
31 |
|
32 | app.start() |
\ | No newline at end of file |