mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Guard against missing stdout/stderr
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
_ = require 'underscore-plus'
|
||||
{fork} = require 'child_process'
|
||||
ChildProcess = require 'child_process'
|
||||
{Emitter} = require 'emissary'
|
||||
Grim = require 'grim'
|
||||
|
||||
@@ -83,7 +83,7 @@ class Task
|
||||
taskPath = taskPath.replace(/\\/g, "\\\\")
|
||||
|
||||
env = _.extend({}, process.env, {taskPath, userAgent: navigator.userAgent})
|
||||
@childProcess = fork '--eval', [bootstrap], {env, silent: true}
|
||||
@childProcess = ChildProcess.fork '--eval', [bootstrap], {env, silent: true}
|
||||
|
||||
@on "task:log", -> console.log(arguments...)
|
||||
@on "task:warn", -> console.warn(arguments...)
|
||||
@@ -102,10 +102,13 @@ class Task
|
||||
@emit(event, args...) if @childProcess?
|
||||
|
||||
# Catch the errors that happened before task-bootstrap.
|
||||
@childProcess.stdout.removeAllListeners()
|
||||
@childProcess.stdout.on 'data', (data) -> console.log data.toString()
|
||||
@childProcess.stderr.removeAllListeners()
|
||||
@childProcess.stderr.on 'data', (data) -> console.error data.toString()
|
||||
if @childProcess.stdout?
|
||||
@childProcess.stdout.removeAllListeners()
|
||||
@childProcess.stdout.on 'data', (data) -> console.log data.toString()
|
||||
|
||||
if @childProcess.stderr?
|
||||
@childProcess.stderr.removeAllListeners()
|
||||
@childProcess.stderr.on 'data', (data) -> console.error data.toString()
|
||||
|
||||
# Public: Starts the task.
|
||||
#
|
||||
@@ -153,8 +156,8 @@ class Task
|
||||
return false unless @childProcess?
|
||||
|
||||
@childProcess.removeAllListeners()
|
||||
@childProcess.stdout.removeAllListeners()
|
||||
@childProcess.stderr.removeAllListeners()
|
||||
@childProcess.stdout?.removeAllListeners()
|
||||
@childProcess.stderr?.removeAllListeners()
|
||||
@childProcess.kill()
|
||||
@childProcess = null
|
||||
|
||||
|
||||
Reference in New Issue
Block a user