forked from DevExpress/DevExtreme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlaunch
executable file
·74 lines (59 loc) · 1.48 KB
/
launch
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
#!/usr/bin/env node
var path = require("path"),
http = require("http"),
gulp = require("gulp"),
childProcess = require("child_process"),
os = require("os");
var PORT = require("./../ports.json").qunit;
if(parseInt(process.versions.node.split('.')[0]) < 6) {
throw "Node version is too low";
}
watchForTests();
childProcess.spawn(
"dotnet",
[ path.join(__dirname, "runner/bin/runner.dll") ],
{ stdio: "inherit" }
);
waitForRunner();
function watchForTests() {
var process = require('process');
process.chdir(path.join(__dirname, "../"));
require('../gulpfile');
gulp.parallel(
'transpile-watch',
'style-compiler-themes-dev'
)();
}
function waitForRunner() {
var timestamp = Date.now();
http.request({ port: PORT }, res => openBrowser())
.on("error", e => setTimeout(
function() {
console.log("waiting...");
waitForRunner();
},
Math.max(0, 300 - Date.now() + timestamp)
))
.end();
}
function openBrowser() {
childProcess.spawn(
getBrowserCommand(),
[ "http://localhost:" + PORT ],
{
shell: true,
detached: true
}
);
}
function getBrowserCommand() {
switch(os.platform()) {
case "win32":
return "start";
case "darwin":
return "open";
case "linux":
return "xdg-open";
}
throw "Not implemented";
}