Created
April 17, 2021 07:00
-
-
Save banyudu/f8d69386e52340c302dcde69cb223d0f to your computer and use it in GitHub Desktop.
Node.js中spawn子进程继承Shell中的颜色等信息
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { spawn } = require('child_process') | |
const params = ['--someoption=somevalue', 'subcommand', 'any other params'] | |
const myCmd = spawn('command-name', params, { stdio:'inherit' }) | |
// 加上 { stdio:'inherit' } 选项之后,子进程会接管父进程的标准输入输出,这样console中的表现就和直接执行子进程相同,而不会丢失颜色、清屏等信息了 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment