forked from ember-learn/ember-api-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run-tests.js
41 lines (34 loc) · 1006 Bytes
/
run-tests.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
const spawn = require('spawndamnit');
const ember = `./node_modules/.bin/ember`;
const userName = process.env['BROWSERSTACK_USERNAME'];
const accessKey = process.env['BROWSERSTACK_ACCESS_KEY'];
const canConnectToBrowserStack =
userName &&
userName.trim().length !== 0 &&
accessKey &&
accessKey.trim().length !== 0;
const hookupLoggers = (proc) => {
proc.on('stdout', (data) => console.log(data.toString()));
proc.on('stderr', (data) => console.error(data.toString()));
};
const execEmberProcess = async (cmd) => {
let proc = spawn(ember, [cmd]);
hookupLoggers(proc);
try {
let { code } = await proc;
if (code !== 0) {
throw Error();
}
} catch (e) {
return process.exit(1); // eslint-disable-line no-process-exit
}
};
(async () => {
if (canConnectToBrowserStack) {
await execEmberProcess('browserstack:connect');
}
await execEmberProcess('exam');
if (canConnectToBrowserStack) {
await execEmberProcess('browserstack:disconnect');
}
})();