 # Run js script
 runScriptAsync = (script_path, args, options) ->
   new Promise (resolve) ->
-    child_process.fork script_path, args, options
-    .on 'exit', -> resolve()
+    proc = child_process.fork script_path, args, options
+    proc.on 'exit', -> resolve()
 
 # Run js script, but suppress stdout and stores it into a string used to resolve
-runScriptSilentAsync = (script_path, args, options) ->
+runScriptReturnStdoutAsync = (script_path, args, options) ->
   new Promise (resolve) ->
     proc = child_process.fork script_path, args, Object.assign({silent: true}, options)
     data = ''

    plugin_dir)

  yield Promise.all (for plugin_dir in plugins_dir
    npmInstallAsync plugin_dir, ['--registry', server, '--no-bin-links', '--silent'])

  yield runScriptAsync npm_exec_path, ['pack'].concat(plugins_dir),
    cwd: tarball_root

  fs.ensureDirSync stage2_app

  # Check npm version
  npm_version = (yield runScriptReturnStdoutAsync npm_exec_path, ['--version']).trim()
  log "You are using npm v#{npm_version}"
  if semver.major(npm_version) == 2
    log "*** USING npm 2 TO BUILD poi IS PROHIBITED ***"
