-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli.js
executable file
·63 lines (46 loc) · 1.27 KB
/
cli.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env node
"use strict";
var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
var minimist = _interopRequire(require("minimist"));
var Servomatic = _interopRequire(require("./servomatic"));
var _path = require("path");
var join = _path.join;
var resolve = _path.resolve;
var normalize = _path.normalize;
var _magicTypes = require("magic-types");
var isStr = _magicTypes.isS;
var isNum = _magicTypes.isN;
var merge = require("magic-merge").merge;
var existsSync = require("fs").existsSync;
var argv = minimist(process.argv.slice(2)),
cwd = process.cwd(),
env = "production",
opts = {
port: 1337
};
if (argv.dir && isStr(argv.dir)) {
opts.dir = findFilePath("dir", argv.dir);
}
if (argv.env && isStr(argv.env)) {
opts.env = argv.env;
}
if (argv.port && isNum(argv.port)) {
opts.port = argv.port;
}
console.log("starting slackomatic with opts", opts);
var servomatic = new Servomatic(opts);
servomatic.start();
function findFilePath(key, file) {
var f = file;
if (key && !file) {
return opts[key];
}
if (resolve(file) !== normalize(file)) {
//~ if ( ! path.isAbsolute(themedir) ) { //needs node 0.12
file = join(cwd, file);
if (existsSync(file)) {
return file;
}
}
return f;
}