src/start.js
/**
     * Run init script (if present)
     */
Run init script (if present)
Run init script ( if present )
function _runInit(callback) {
      let initJS = join(process.cwd(), 'scripts', 'sandbox-startup.js')
      let initPy = join(process.cwd(), 'scripts', 'sandbox-startup.py')
      let initRb = join(process.cwd(), 'scripts', 'sandbox-startup.rb')
      let script
      if (exists(initJS))
        script = initJS
      else if (exists(initPy))
        script = initPy
      else if (exists(initRb))
        script = initRb
      if (script) {
        let now = Date.now()
        update.status('Running sandbox init script')
        let run
        let runtime
        if (script === initJS) {
          let js = require(script)
          run = js(arc)
          runtime = 'Node.js'
        }
        else if (script === initPy) {
          run = exec(`python ${initPy}`)
          runtime = 'Python'
        }
        else {
          run = exec(`ruby ${initRb}`)
          runtime = 'Ruby'
        }
        Promise.resolve(run).then(
          function done(result) {
            if (result) {
              update.done(`Init (${runtime}):`)
              let print = result.toString().trim().split('\n').map(l => `    ${l.trim()}`).join('\n')
              console.log(print)
            }
            update.done(`Sandbox init script ran in ${Date.now() - now}ms`)
            callback()
          }
        )
      }
      else callback()
    }
function _runInit ( callback ) { let initJS = join ( process . cwd ( ) , 'scripts' , 'sandbox-startup.js' ) let initPy = join ( process . cwd ( ) , 'scripts' , 'sandbox-startup.py' ) let initRb = join ( process . cwd ( ) , 'scripts' , 'sandbox-startup.rb' ) let script if ( exists ( initJS ) ) script = initJS else if ( exists ( initPy ) ) script = initPy else if ( exists ( initRb ) ) script = initRb if ( script ) { let now = Date . now ( ) update . status ( 'Running sandbox init script' ) let run let runtime if ( script === initJS ) { let js = require ( script ) run = js ( arc ) runtime = 'Node.js' } else if ( script === initPy ) { run = exec ( ` ${ initPy } ` ) runtime = 'Python' } else { run = exec ( ` ${ initRb } ` ) runtime = 'Ruby' } Promise . resolve ( run ) . then ( function done ( result ) { if ( result ) { update . done ( ` ${ runtime } ` ) let print = result . toString ( ) . trim ( ) . split ( '\n' ) . map ( l => ` ${ l . trim ( ) } ` ) . join ( '\n' ) console . log ( print ) } update . done ( ` ${ Date . now ( ) - now } ` ) callback ( ) } ) } else callback ( ) }
Run init script (if present)
Run init script ( if present )
// eslint-disable-next-line