Created
January 21, 2017 06:01
-
-
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
This file contains hidden or 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 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