import { spawn } from 'child_process' ; export function runCmd ( cmd , args , callBack , logger ? ) { const child = spawn ( cmd , args ) ; if ( logger ) { child . on ( 'error' , ( e ) => logger ( 'error: ' + e ) ) ; child . stderr . on ( 'data' , ( e ) => logger ( 'stderr: ' + e ) ) ; } let resp = '' ; child . stdout . on ( 'data' , ( buffer ) => { resp += buffer . toString ( ) ; } ) ; child . stdout . on ( 'end' , ( ) => { callBack ( resp ) ; } ) ; } export function countOccurrences ( s , c ) { return ( s . match ( c ) || [ ] ) . length ; }