我认为这很简单,但以下内容无法按预期工作。
我想将数据wc
从 Node.
const {spawnSync} = require('child_process')
const {Readable} = require('stream')
const textStream = new Readable()
textStream.push("one two three")
textStream.push(null)
const stdio = [textStream, process.stdout, process.stderr]
spawnSync('wc', ["-c"], { stdio })
不幸的是,这会引发错误:
选项“stdio”的值“Readable { ... } 无效
来自的相关代码internal/child_process.js
不会立即揭示预期的有效选项是什么。