2017-08-25 29 views
0

正在查看磁帶+點擊視頻並試圖使其工作。
操作系統:Windows 7 的Git的bash shell標準輸出不是tty。使用bash作爲節點+磁帶+ tap-spec

node main.js | ./node_modules/.bin/tap-spec 

stdout不是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 不能解決問題。

回答

1

診斷:

即使世界沒有錯的代碼,我得到下面的輸出:(OS:ArchLinux的)

add: two numbers add correctly 

    ✔ should be equal 


    total:  1 
    passing: 1 
    duration: 14ms 

它可能與Windows 7 Git Bash Shell

我讀的地方有問題:通過管道發送輸出已損壞Git Bash

要放棄它運行以下命令:

node -p -e "Boolean(process.stdout.isTTY)" 

爲它工作,你需要以下的輸出:true


解決方案(適用於Windows):

$ node -p -e "Boolean(process.stdout.isTTY)" 
false 

使用winpty tool,它創建了一個隱藏的控制檯,並在它和Cygwin/GitBashshell之間封裝了I/O模擬pty:

$ winpty node -p -e "Boolean(process.stdout.isTTY)" 
true 

READ MORE : Node.js doesn't run as tty on windows/cygwin Issue#3006

+0

你是如何運行的winpty命令是從我原來的職位有什麼不同?它失敗了。你打字的確切命令是什麼?謝謝 – FreddyNoNose

+1

@FreddyNoNose,就像我在回答中聲明的那樣:winpty命令將被編譯爲[winpty工具](https://github.com/rprichard/winpty) – EMX

+1

@FreddyNoNose:我不使用Windows,但是如果你按照答案你會得到它與Git Bash殼牌 – EMX

相關問題