-
Notifications
You must be signed in to change notification settings - Fork 3
/
meshcommander.js
59 lines (48 loc) · 1.17 KB
/
meshcommander.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
/**
* @description MeshCommander
* @author Ylian Saint-Hilaire
* @copyright Intel Corporation 2018
* @license Apache-2.0
* @version v0.0.3
*/
function CreateMeshCommanderServer(args) {
var obj = {};
obj.args = require("minimist")(process.argv.slice(2));
// Start the Meshcommander server
obj.Start = function () {
obj.webserver = require("./webserver.js").CreateWebServer(obj.args);
};
// Stop the Meshcommander server
obj.Stop = function () {
if (obj.webserver) {
obj.webserver = null;
}
};
return obj;
}
function launchBrowser() {
var obj = {};
obj.args = require("minimist")(process.argv.slice(2)); // slice off the first 2 default args
const port = obj.args.port || 3000;
let browser = "";
switch (obj.args.browser) {
case "chrome":
browser = "chrome";
break;
case "edge":
browser = "msedge";
break;
case "none":
browser = null;
break;
default:
browser = "chrome";
break;
}
if (browser) {
var child_process = require("child_process");
child_process.exec(`start ${browser} http://localhost:${port}`);
}
}
launchBrowser();
CreateMeshCommanderServer().Start();