1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | Object.defineProperty(exports, "__esModule", { value: true });
|
8 | const childProcess = require("child_process");
|
9 | const logger = require("./logger");
|
10 | function spawnSync(cmd, args, options) {
|
11 | let exec;
|
12 | logger.debug(`spawnSync: ${cmd} ${args.join(' ')}`);
|
13 | exec = childProcess.spawnSync(cmd, args, options);
|
14 | if (exec.error && exec.error.code === 'ENOENT' && process.platform === 'win32') {
|
15 | logger.debug("Invoking patched sapwnSync due to Windows' libuv bug");
|
16 | exec = childProcess.spawnSync(`${cmd}.cmd`, args, options);
|
17 | }
|
18 | return {
|
19 | stdout: exec.stdout.toString().trim(),
|
20 | stderr: exec.stderr.toString().trim(),
|
21 | status: exec.status,
|
22 | };
|
23 | }
|
24 | exports.spawnSync = spawnSync;
|
25 | function spawnSyncStream(cmd, args, options) {
|
26 | let proc;
|
27 | let err;
|
28 | if (!options) {
|
29 | options = {};
|
30 | }
|
31 | options.stdio = ['pipe', process.stdout, process.stderr];
|
32 | logger.debug(`spawnSyncStream: ${cmd} ${args.join(' ')}`);
|
33 | proc = childProcess.spawnSync(cmd, args, options);
|
34 | if (proc.status !== 0) {
|
35 | err = new Error();
|
36 | err.code = proc.status;
|
37 | err.message = `Child process terminated with error code ${err.code}`;
|
38 | throw err;
|
39 | }
|
40 | return proc;
|
41 | }
|
42 | exports.spawnSyncStream = spawnSyncStream;
|
43 | function execSync(cmd, options) {
|
44 | if (!options) {
|
45 | options = {};
|
46 | }
|
47 | logger.debug(`execSync: ${cmd}`);
|
48 | options.stdio = ['pipe', process.stdout, process.stderr];
|
49 | return childProcess.execSync(cmd, options);
|
50 | }
|
51 | exports.execSync = execSync;
|
52 | function execSyncInteractiveStream(cmd, options) {
|
53 | if (!options) {
|
54 | options = {};
|
55 | }
|
56 | logger.debug(`execSyncInteractiveStream: ${cmd}`);
|
57 | options.stdio = 'inherit';
|
58 | return childProcess.execSync(cmd, options);
|
59 | }
|
60 | exports.execSyncInteractiveStream = execSyncInteractiveStream;
|
61 |
|
\ | No newline at end of file |