Node.js execa:如何完成对进程标准输入的写入

Node.js execa: how to finish writing to process' stdin

我正在尝试使用 execa 将标准输入转换为 docx 文件。我等待的承诺悬而未决。我试过用 \n 终止标准输入,但这不起作用。

const process  = execa('pandoc', ['-', '-o', 'file.docx'])
process.stdin.write('input to be made into a docx file')
process.stdin.write('\n')
const result = await process

好的,我知道了。节点可写流有一个 end() 方法。

const process  = execa('pandoc', ['-', '-o', 'file.docx'])
process.stdin.write('input to be made into a docx file')
process.stdin.end();
const result = await process