Skip to content

Instantly share code, notes, and snippets.

@alexrqs
Created August 26, 2019 16:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexrqs/4ec3971c99fa716d0421876ff4cac0c3 to your computer and use it in GitHub Desktop.
Save alexrqs/4ec3971c99fa716d0421876ff4cac0c3 to your computer and use it in GitHub Desktop.
spawn child process with colors nodejs
#!/usr/bin/env node
if (process.platform == 'win32') {
process.exit(0)
}
const { spawn } = require('child_process')
const packages = ['webpack']
const yarnAdd = ['yarn', 'add', '-D']
.concat(packages)
.join(' ')
// in this form spawn don't need .stdio.on() || .stderr.on() || etc...
spawn('/bin/sh', ['-c', yarnAdd], { stdio: [0,1,2] })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment