-
Notifications
You must be signed in to change notification settings - Fork 12
/
jspm-server.js
executable file
·77 lines (71 loc) · 1.86 KB
/
jspm-server.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env node
var liveServer = require("./index");
var opts = {
proxyServer: null,
port: process.env.PORT,
open: true,
logLevel: 2,
inclExtensions: [],
exclExtensions: []
};
for (var i = process.argv.length-1; i >= 2; --i) {
var arg = process.argv[i];
if (arg.indexOf("--port=") > -1) {
var portString = arg.substring(7);
var portNumber = parseInt(portString, 10);
if (portNumber == portString) {
opts.port = portNumber;
process.argv.splice(i, 1);
}
}
else if (arg.indexOf("--proxy=") > -1) {
opts.proxyServer = arg.substring(8);
process.argv.splice(i, 1);
}
else if (arg.indexOf("--open=") > -1) {
var path = arg.substring(7);
if (path.indexOf('/') != 0) {
path = '/' + path;
}
opts.open = path;
process.argv.splice(i, 1);
}
else if (arg.indexOf("--only-exts=") > -1) {
var extensions = []
var extArgs = arg.substring(12);
extArgs = extArgs.replace(/\./g, '');
if(extArgs) {
extensions = extArgs.split(/,\s?/);
}
if(extensions.length) {
opts.inclExtensions = extensions;
process.argv.splice(i, 1);
}
}
else if (arg.indexOf("--ignore-exts=") > -1) {
var extensions = []
var extArgs = arg.substring(14);
extArgs = extArgs.replace(/\./g, '');
if(extArgs) {
extensions = extArgs.split(/,\s?/);
}
if(extensions.length) {
opts.exclExtensions = extensions;
process.argv.splice(i, 1);
}
}
else if (arg == "--no-browser") {
opts.open = false;
process.argv.splice(i, 1);
} else if (arg == "--quiet" || arg == "-q") {
opts.logLevel = 0;
process.argv.splice(i, 1);
} else if (arg == "--help" || arg == "-h") {
console.log('Usage: jspm-server [-h|--help] [-q|--quiet] [--port=PORT] [--open=PATH] [--only-exts=EXTENSIONS] [--ignore-exts=EXTENSIONS] [--proxy=PROXY_PATH] [--no-browser] [PATH]');
process.exit();
}
}
if (process.argv[2]) {
process.chdir(process.argv[2]);
}
liveServer.start(opts);