Skip to content

Instantly share code, notes, and snippets.

@reqshark
Created January 21, 2017 06:01
Show Gist options
  • Save reqshark/a6c31d59cc58262686e7a96d726520ae to your computer and use it in GitHub Desktop.
Save reqshark/a6c31d59cc58262686e7a96d726520ae to your computer and use it in GitHub Desktop.
`$ ls -la` to list files on unix. for success, call process.exit with zero
const n = [ 'error', 'stdout', 'stderr' ]
require('child_process').exec('ls -la', function output () {
return []
.slice
.call ( arguments ) // or do [].from(arguments)
.reduce ( ( p, c, i ) => {
if ( c )
console.log(`\n\n${n[i]}:\n\n${c}`)
return p
}, process.exit ) ( 0 )
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment