$ git clone https://github.com/bensmithett/webpack-css-example
Cloning into 'webpack-css-example'...
remote: Counting objects: 179, done.
remote: Total 179 (delta 0), reused 0 (delta 0), pack-reused 179
Receiving objects: 100% (179/179), 24.07 KiB | 0 bytes/s, done.
Resolving deltas: 100% (79/79), done.
Checking connectivity... done
然而,当我试图将其重定向到一个文件,我只看到这一点:
Cloning into 'webpack-css-example'...
这里是我的尝试:
$ git clone https://github.com/bensmithett/webpack-css-example 2>&1 | tee out.log
$ cat out.log
Cloning into 'sample-data'...
我在Node.js的试了一下为好,它做同样的事情:
const fs = require('fs');
const child = spawn('git clone https://github.com/bensmithett/webpack-css-example');
child.stdout.on('data', function(data){
console.log(String(data));
});
child.stderr.on('data', function(data){
console.log(String(data));
});
// Cloning into 'webpack-css-example'...
为什么所有的remote:等东西没有通过管道连接到stdin/stderr?有什么方法可以捕获输出吗?如果没有,发生了什么事情使得输出显示在终端中,但它没有通过stdout或stderr传递?