Passed
Push — master ( 70a68e...ca9249 )
by Dmytro
02:22
created

conditional-test.js ➔ main   A

Complexity

Conditions 3

Size

Total Lines 18
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 18
c 0
b 0
f 0
rs 9.8
cc 3
1
import { spawn, execSync } from 'child_process';
2
import path from 'path';
3
import fs from 'fs-extra';
4
import {
5
    getTestCommand,
6
    getPrepareCommands
7
} from '../utils';
8
9
async function main() {
10
    const { platform, versions } = process;
11
12
    console.log(JSON.stringify({ platform, versions }));
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
13
    const packageJSON = await fs.readJSON(path.join(process.cwd(), 'package.json'));
14
    const config = packageJSON['node-package-tester'];
15
    const testCommand = getTestCommand(config, { platform, versions });
16
    const prepareCommands = getPrepareCommands(config, { platform, versions });
17
18
    console.log('prepareCommands:', prepareCommands);
19
    for (const prepareCommand of prepareCommands) {
20
        execSync(prepareCommand);
21
    }
22
23
    const childProcess = spawn('npm', [ 'run', testCommand ], { shell: true, stdio: 'inherit' });
24
25
    childProcess.on('exit', (code) => process.exit(code));
0 ignored issues
show
Compatibility Debugging Code Best Practice introduced by
Use of process.exit() is discouraged as it will potentially stop the complete node.js application. Consider quitting gracefully instead by throwing an Error.
Loading history...
26
}
27
28
main();
29
30