stdout不是tty.将bash用于节点+磁带+点击规范 [英] stdout is not a tty. Using bash for node + tape + tap-spec
问题描述
正在观看录像带+点击视频,并尝试使其正常工作.
作业系统:Windows 7
Git Bash Shell
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不是tty.
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节点main.js | ./node_modules/.bin/tap-spec 不能解决问题.
winpty node main.js | ./node_modules/.bin/tap-spec doesn't fix the problem.
推荐答案
诊断:
代码没有错,我得到以下输出:(OS:ArchLinux)
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
可能是Windows 7 Git Bash Shell
我在某处读到:通过管道发送输出已被Git Bash破坏
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)"
要使其正常工作,您需要以下输出:true
For it to work you need the following output : true
$ node -p -e "Boolean(process.stdout.isTTY)"
false
使用 winpty工具,它会创建一个隐藏的控制台并封送它与Cygwin之间的I/O. /GitBashshell模拟pty:
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
> 更多信息:Node.js在Windows/cygwin上无法作为tty运行问题#3006
READ MORE : Node.js doesn't run as tty on windows / cygwin Issue#3006
这篇关于stdout不是tty.将bash用于节点+磁带+点击规范的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!