nl_tokens: Run shell command
pl_tokens: function sh ( cmd , exitOnError , cb ) { const child = exec ( cmd , { encoding : 'utf8' , timeout : 1000 * 60 * 2 , // 2 min; just want to make sure nothing gets detached forever. } ) ; let stdout = '' ; child . stdout . on ( 'data' , ( data ) => { stdout += data ; process . stdout . write ( data ) ; } ) ; child . stderr . on ( 'data' , ( data ) => { process . stdout . write ( data ) ; } ) ; child . on ( 'close' , ( code ) => { if ( code > 0 ) { if ( exitOnError ) { if ( typeof cb === 'function' ) { cb ( new Error ( ` ${ code } ${ cmd } ` ) ) ; } else { process . stdout . write ( ` ${ code } ${ cmd } \n ` ) ; process . exit ( code ) ; } } else { notifier . notify ( { title : cmd , <mask> : stdout , sound : true , } ) ; } } if ( typeof cb === 'function' ) cb ( ) ; } ) ; }