1 | #!/usr/bin/env node
|
2 |
|
3 | var path = require('path');
|
4 | var fs = require('fs');
|
5 | var program = require('commander');
|
6 | var pkg = require('../package.json');
|
7 |
|
8 | program
|
9 | .version(pkg.version)
|
10 | .usage('<target>')
|
11 | .option('-d, --debug-log', 'print debug log')
|
12 | .on('--help', function(){
|
13 | console.log(' Examples:');
|
14 | console.log('');
|
15 | console.log(' $ ems start');
|
16 | console.log(' $ ems start my-spa-application');
|
17 | console.log(' $ ems start /path/to/my-spa-application');
|
18 | console.log('');
|
19 | })
|
20 | .parse(process.argv);
|
21 |
|
22 | if(program.debugLog) {
|
23 | process.env.DEBUG = 'express-mincer-spa*';
|
24 | }
|
25 |
|
26 | var target = program.args[0] || process.cwd();
|
27 | var targetPath = path.resolve(process.cwd(), target);
|
28 |
|
29 | if(fs.existsSync(targetPath)) {
|
30 | var app = require(targetPath);
|
31 | app.start();
|
32 | } else {
|
33 | console.error('Target application '+target+' does not exists');
|
34 | }
|