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 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 | function takeParamFromArgs(param){
|
36 | options[param] = argv[param] || argv[param[0]] || options[param]
|
37 | }
|
38 |
|
39 | ;['base', 'port'].forEach(takeParamFromArgs)
|
40 |
|
41 | var App = require('./lib/app.js')
|
42 |
|
43 | var app = new App(options)
|
44 |
|
45 | app.start() |
\ | No newline at end of file |