-
Notifications
You must be signed in to change notification settings - Fork 188
Expand file tree
/
Copy pathrunProcess.ts
More file actions
40 lines (34 loc) · 809 Bytes
/
runProcess.ts
File metadata and controls
40 lines (34 loc) · 809 Bytes
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
import path from 'path';
import { spawnSync } from 'child_process';
import { ExecOutput } from './common';
const NYC_BIN = path.resolve(__dirname, '../../node_modules/.bin/nyc');
const NYC_ARGS = [
'--silent',
'--no-clean',
'--exclude-after-remap',
'false',
'--cwd',
path.join(__dirname, '../../'),
];
function getEnv() {
return {
...process.env,
NODE_ENV: 'development',
};
}
export function runProcessSync(dir: string, args: Array<string>): ExecOutput {
let cwd = dir;
const isRelative = cwd[0] !== '/';
if (isRelative) {
cwd = path.resolve(__dirname, cwd);
}
const result = spawnSync(NYC_BIN, [...NYC_ARGS, ...args], {
cwd,
env: getEnv(),
});
return {
...result,
stdout: result.stdout.toString(),
stderr: result.stderr.toString(),
};
}