Skip to content

Commit 3fd012b

Browse files
committed
Fix the error with redirecting stdout to a file on Windows
Without this fix a command like `test262-harness > test.log` leads to this ``` d:\project\node_modules\test262-harness\lib\simpleReporter.js:38 process.stdout.clearLine(); ^ TypeError: process.stdout.clearLine is not a function at Stream.<anonymous> (d:\project\node_modules\test262-harness\lib\simpleReporter.js:38:20) at Stream.stream.write (d:\project\node_modules\test262-harness\node_modules\through\index.js:2 6:11) at d:\project\node_modules\test262-harness\node_modules\highland\lib\index.js:882:23 at Stream.s._send (d:\project\node_modules\test262-harness\node_modules\highland\lib\index.js:1 139:9) at Stream.write (d:\project\node_modules\test262-harness\node_modules\highland\lib\index.js:122 0:18) at Stream._send (d:\project\node_modules\test262-harness\node_modules\highland\lib\index.js:657 :32) at Stream.write (d:\project\node_modules\test262-harness\node_modules\highland\lib\index.js:122 0:18) at Stream._generator_push (d:\project\node_modules\test262-harness\node_modules\highland\lib\in dex.js:489:18) at d:\project\node_modules\test262-harness\node_modules\highland\lib\index.js:3476:21 at d:\project\node_modules\test262-harness\node_modules\highland\lib\index.js:1173:9 ```
1 parent 79290eb commit 3fd012b

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

lib/simpleReporter.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@ function actualString(test) {
3434
}
3535

3636
module.exports = through(function(data) {
37-
process.stdout.clearLine();
38-
process.stdout.cursorTo(0);
37+
if (process.stdout.clearLine && process.stdout.cursorTo) {
38+
process.stdout.clearLine();
39+
process.stdout.cursorTo(0);
40+
}
3941

4042
if(data.pass) {
4143
state.pass++;
@@ -49,8 +51,10 @@ module.exports = through(function(data) {
4951
" Got: " + actualString(data) + "\n\n");
5052
}
5153
}, function() {
52-
process.stdout.clearLine();
53-
process.stdout.cursorTo(0);
54+
if (process.stdout.clearLine && process.stdout.cursorTo) {
55+
process.stdout.clearLine();
56+
process.stdout.cursorTo(0);
57+
}
5458
console.log("Ran " + (state.pass + state.fail) + " tests")
5559
console.log(state.pass + " passed")
5660
console.log(state.fail + " failed")

0 commit comments

Comments
 (0)