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