forked from a7359475/layaair-cmd
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlayaair-cmd-open.js
40 lines (36 loc) · 912 Bytes
/
layaair-cmd-open.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const path = require("path");
const program = require("commander");
const spawn = require("child_process").spawn;
const fs = require("fs");
const
{
printOk,
printErr,
printQuotation,
tr
} = require("./print.js");
program
.version("0.1.1")
.usage("[port] [args]")
.option('-p <port>', tr("resource directory."))
.option('-s', tr("don't open browser"))
.option('-h <hostname>', tr("with hostname, such as layaair-cmd open -h localhost"))
.option('-d <directory>', tr("with folder"))
.option('-f', tr("enable html5 history"))
.parse(process.argv);
let args = process.argv.slice(2);
args.unshift(path.resolve(__dirname, 'node_modules', 'anywhere', 'bin', 'anywhere'));
var sp = require("child_process").spawn(
"node",
args,
{
cwd: process.cwd()
});
sp.stdout.on('data', function(data)
{
printQuotation(data.toString());
});
sp.stderr.on('data', function(data)
{
printErr(data.toString());
});