Skip to content

Commit

Permalink
avoid piping in data via stdin to avoid stderr redirection bug in nod…
Browse files Browse the repository at this point in the history
…e 7's child process
  • Loading branch information
michaelglass committed Feb 9, 2017
1 parent d7bc645 commit 959fda0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
30 changes: 16 additions & 14 deletions bin/elm-test
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ var compile = require("node-elm-compiler").compile,
temp = require("temp").track(), // Automatically cleans up temp files.
util = require("util"),
_ = require("lodash"),
childProcess = require("child_process");
childProcess = require("child_process"),
findup = require("findup-sync");

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

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

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

runnerProcess.on('exit', function (exitCode) {
process.exit(exitCode);
});
console.log("Bootstrapped test script")

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

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

runnerProcess.stdin.end();
})
runnerProcess.on('exit', function (exitCode) {
process.exit(exitCode);
});

reader.pipe(runnerProcess.stdin);

console.log("Running tests...");
console.log("Running tests...");
});
});
});
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "elm-test",
"version": "0.16.0",
"version": "0.16.1",
"description": "Run elm-test suites.",
"main": "elm-test.js",
"engines": {
Expand Down Expand Up @@ -31,6 +31,7 @@
"fs-extra": "0.26.2",
"lodash": "3.10.1",
"node-elm-compiler": "2.0.0",
"temp": "0.8.3"
"temp": "0.8.3",
"findup-sync": "0.4.3"
}
}

0 comments on commit 959fda0

Please sign in to comment.