module author : Alex Chao, Nov 7th, 2019
 *  function param param param returns changelog const childProcess = require ( 'child_process' ) ; const checkForRunningServer = ( portNumber , once , allowServerTimeoutConfigSetting = 3000 ) => { let portOpen = false ; let allTerminalText ; const bashTerminal = childProcess . spawn ( 'bash' ) ; bashTerminal . stdout . on ( 'data' , ( data ) => { allTerminalText = data . toString ( ) ; portOpen = allTerminalText . includes ( 'node' ) || allTerminalText . includes ( 'com.docke' ) ; } ) ; return new Promise ( ( resolve ) => { let numRuns = 0 ; let timeoutId ; const intervalLsofToBash = setInterval ( ( ) => { bashTerminal . stdin . write ( `lsof -i :${ portNumber }\n` ) ; if ( portOpen ) { clearInterval ( intervalLsofToBash ) ; if ( timeoutId ) clearTimeout ( timeoutId ) ; bashTerminal . stdin . end ( ) ; resolve ( true ) ; } if ( once && numRuns > 1 ) { clearInterval ( intervalLsofToBash ) ; if ( timeoutId ) clearTimeout ( timeoutId ) ; bashTerminal . stdin . end ( ) ; resolve ( portOpen ) ; } numRuns += 1 ; } , 200 ) ; if ( ! once ) { timeoutId = setTimeout ( ( ) => { clearInterval ( intervalLsofToBash ) ; bashTerminal . stdin . end ( ) ; resolve ( false ) ; } , allowServerTimeoutConfigSetting ) ; } } ) ; } ; module . exports = checkForRunningServer ;