UNPKG

914 BPlain TextView Raw
1#!/usr/bin/env node
2
3var path = require('path');
4var fs = require('fs');
5var program = require('commander');
6var pkg = require('../package.json');
7
8program
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
22if(program.debugLog) {
23 process.env.DEBUG = 'express-mincer-spa*';
24}
25
26var target = program.args[0] || process.cwd();
27var targetPath = path.resolve(process.cwd(), target);
28
29if(fs.existsSync(targetPath)) {
30 var app = require(targetPath);
31 app.start();
32} else {
33 console.error('Target application '+target+' does not exists');
34}