Was looking at a tape + tap video and tried to get it to work.
OS: Windows 7
Git Bash Shell
node main.js | ./node_modules/.bin/tap-spec
stdout is not a tty.
main.js:
var test = require('tape');
var add = require('./add');
test('add: two numbers add correctly', function(t) {
var actual = add(1,2);
var expected = 3;
t.equal(actual, expected);
t.end();
});
add.js:
module.exports = function(a, b) {
return a + b;
};
winpty node main.js | ./node_modules/.bin/tap-spec doesn't fix the problem.
Diagnose :
Theres nothing wrong with the code, I get the following output : (OS : ArchLinux)
add: two numbers add correctly
✔ should be equal
total: 1
passing: 1
duration: 14ms
Its probably a problem with Windows 7 Git Bash Shell
I read somewhere : sending output through a pipe is broken with Git Bash
To discard it run the following command :
node -p -e "Boolean(process.stdout.isTTY)"
For it to work you need the following output : true
Solution (for Windows):
$ node -p -e "Boolean(process.stdout.isTTY)"
false
Using the winpty tool, it creates a hidden console and marshals I/O between it and Cygwin/GitBashshell emulated pty :
$ winpty node -p -e "Boolean(process.stdout.isTTY)"
true
READ MORE : Node.js doesn't run as tty on windows / cygwin Issue#3006
来源:https://stackoverflow.com/questions/45890339/stdout-is-not-a-tty-using-bash-for-node-tape-tap-spec