简体   繁体   中英

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

I'm trying to use execa to convert stdin to a docx file. The promise I await is hanging and never completes. I've tried terminating stdin with a \\n , but that doesn't work.

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

Okay I got it. Node writable streams have a end() method.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM