Fre*_*ose 9 node.js git-bash node.js-tape
正在看磁带 + 点击视频并试图让它工作。
操作系统:Windows 7 Git Bash Shell
node main.js | ./node_modules/.bin/tap-spec
Run Code Online (Sandbox Code Playgroud)
stdout 不是 tty。
主要.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();
});
Run Code Online (Sandbox Code Playgroud)
添加.js:
module.exports = function(a, b) {
return a + b;
};
Run Code Online (Sandbox Code Playgroud)
winpty 节点 main.js | ./node_modules/.bin/tap-spec 不能解决问题。
Tho*_*ban 23
只是为了添加我的案例,我面临着类似的问题。使用 winpty 的两种解决方案都没有帮助,因此我在 usingnode.exe
而不是node
运行脚本时使用了不同的提示(在我的情况下来自 Git bash)。
不工作:
node myscript.js < some-input.txt > some-output.txt
Run Code Online (Sandbox Code Playgroud)
在职的:
node.exe myscript.js < some-input.txt > some-output.txt
Run Code Online (Sandbox Code Playgroud)
代码没有任何问题,我得到以下输出:(操作系统:ArchLinux)
add: two numbers add correctly
? should be equal
total: 1
passing: 1
duration: 14ms
Run Code Online (Sandbox Code Playgroud)
它可能是一个问题 Windows 7 Git Bash Shell
我在某处读到:通过管道发送输出被 Git Bash 破坏了
要丢弃它,请运行以下命令:
node -p -e "Boolean(process.stdout.isTTY)"
Run Code Online (Sandbox Code Playgroud)
要使其工作,您需要以下输出: true
$ node -p -e "Boolean(process.stdout.isTTY)"
false
Run Code Online (Sandbox Code Playgroud)
使用winpty 工具,它创建一个隐藏的控制台并在它和 Cygwin/GitBashshell 模拟 pty 之间编组 I/O:
$ winpty node -p -e "Boolean(process.stdout.isTTY)"
true
Run Code Online (Sandbox Code Playgroud)
阅读更多:Node.js 在 windows / cygwin 上不作为 tty 运行问题#3006
归档时间: |
|
查看次数: |
11878 次 |
最近记录: |