Skip to content

Commit 959fda0

Browse files
committed
avoid piping in data via stdin to avoid stderr redirection bug in node 7's child process
1 parent d7bc645 commit 959fda0

2 files changed

Lines changed: 19 additions & 16 deletions

File tree

bin/elm-test

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ var compile = require("node-elm-compiler").compile,
1111
temp = require("temp").track(), // Automatically cleans up temp files.
1212
util = require("util"),
1313
_ = require("lodash"),
14-
childProcess = require("child_process");
14+
childProcess = require("child_process"),
15+
findup = require("findup-sync");
1516

1617
var elm = {
1718
'elm-package': 'elm-package'
@@ -102,23 +103,24 @@ temp.open({ prefix:'elm_test_', suffix:'.js' }, function(err, info) {
102103

103104
console.log("Successfully compiled", testFile);
104105

105-
var runnerOpts = {stdio: ["pipe", "inherit", "inherit"]};
106-
var runnerProcess = childProcess.spawn("node", [], runnerOpts);
106+
// append suffix to temp file
107+
fs.appendFile(dest, suffix, function(err){
108+
if (err) throw(err);
107109

108-
runnerProcess.on('exit', function (exitCode) {
109-
process.exit(exitCode);
110-
});
110+
console.log("Bootstrapped test script")
111111

112-
var reader = fs.createReadStream(dest);
112+
// add node_modules to NODE_PATH so the temporary file can require
113+
// local modules
114+
var pathToNodeModules = findup("node_modules");
115+
process.env.NODE_PATH = _.compact([process.env.NODE_PATH, pathToNodeModules]).join(':');
113116

114-
reader.on("end", function() {
115-
runnerProcess.stdin.write(suffix);
117+
var runnerProcess = childProcess.spawn("node", [dest], {stdio: 'inherit'});
116118

117-
runnerProcess.stdin.end();
118-
})
119+
runnerProcess.on('exit', function (exitCode) {
120+
process.exit(exitCode);
121+
});
119122

120-
reader.pipe(runnerProcess.stdin);
121-
122-
console.log("Running tests...");
123+
console.log("Running tests...");
124+
});
123125
});
124126
});

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "elm-test",
3-
"version": "0.16.0",
3+
"version": "0.16.1",
44
"description": "Run elm-test suites.",
55
"main": "elm-test.js",
66
"engines": {
@@ -31,6 +31,7 @@
3131
"fs-extra": "0.26.2",
3232
"lodash": "3.10.1",
3333
"node-elm-compiler": "2.0.0",
34-
"temp": "0.8.3"
34+
"temp": "0.8.3",
35+
"findup-sync": "0.4.3"
3536
}
3637
}

0 commit comments

Comments
 (0)