0
linuxの|コマンドのstdout
を次のコマンドのstdin
にパイプするには、node.jsアプリケーションのパイプ(パイプ)を使用します。両方のコマンドはspawnSync
で生成されています。spawnSyncのstdoutを別のspawnSync stdinに送信
この(擬似コード)コマンドラインで期待どおりに動作します:
$ command1 -arg1 file | command2 arg2
> someoutput
しかし、これにはない:
const spawnSync = require('child_process').spawnSync;
const c1Spawn = spawnSync('command1', ['arg1', 'file']);
const c2Spawn = spawnSync('command2', ['arg2'], { input: c1Spawn.output });
const someoutput = c2Spawn.output;