Skip to content
This repository was archived by the owner on Jun 3, 2023. It is now read-only.

Commit 930810b

Browse files
author
Victor Navarro
committed
chore: try using shell script
1 parent 052f081 commit 930810b

File tree

9 files changed

+7742
-105
lines changed

9 files changed

+7742
-105
lines changed

dist/exec-child.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
if (require.main !== module) {
2+
throw new Error('This file should not be required');
3+
}
4+
5+
var childProcess = require('child_process');
6+
var fs = require('fs');
7+
8+
var paramFilePath = process.argv[2];
9+
10+
var serializedParams = fs.readFileSync(paramFilePath, 'utf8');
11+
var params = JSON.parse(serializedParams);
12+
13+
var cmd = params.command;
14+
var execOptions = params.execOptions;
15+
var pipe = params.pipe;
16+
var stdoutFile = params.stdoutFile;
17+
var stderrFile = params.stderrFile;
18+
19+
var c = childProcess.exec(cmd, execOptions, function (err) {
20+
if (!err) {
21+
process.exitCode = 0;
22+
} else if (err.code === undefined) {
23+
process.exitCode = 1;
24+
} else {
25+
process.exitCode = err.code;
26+
}
27+
});
28+
29+
var stdoutStream = fs.createWriteStream(stdoutFile);
30+
var stderrStream = fs.createWriteStream(stderrFile);
31+
32+
c.stdout.pipe(stdoutStream);
33+
c.stderr.pipe(stderrStream);
34+
c.stdout.pipe(process.stdout);
35+
c.stderr.pipe(process.stderr);
36+
37+
if (pipe) {
38+
c.stdin.end(pipe);
39+
}

0 commit comments

Comments
 (0)