Node.js中是否有办法区分使用xargs调用的脚本和使用管道调用的脚本?
$ echo test | xargs node test.js
$ echo test | node test.js
我希望得到与process.stdin.isTTY
described in the docs
答案 0 :(得分:0)
您应该能够使用here描述的解决方案来检测某些数据是否正在通过管道传输到节点进程。
在xargs的情况下,流被传递给xargs而不是节点,因此尝试从stdin读取应该为null。