mirror of
https://github.com/atom/atom.git
synced 2026-01-22 13:28:01 -05:00
Put node directory in PATH when spawning
This ensures the node used by the spawned process is the one bundled with Atom. This should prevent any "env: node: No such file or directory" errors when spawning a node bin script such as nak. Refs #514
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
ChildProcess = require 'child_process'
|
||||
path = require 'path'
|
||||
_ = require 'underscore'
|
||||
|
||||
module.exports =
|
||||
class BufferedProcess
|
||||
@@ -6,6 +8,8 @@ class BufferedProcess
|
||||
killed: false
|
||||
|
||||
constructor: ({command, args, options, stdout, stderr, exit}={}) ->
|
||||
options ?= {}
|
||||
@addNodeDirectoryToPath(options)
|
||||
@process = ChildProcess.spawn(command, args, options)
|
||||
|
||||
stdoutClosed = true
|
||||
@@ -36,6 +40,14 @@ class BufferedProcess
|
||||
processExited = true
|
||||
triggerExitCallback()
|
||||
|
||||
addNodeDirectoryToPath: (options) ->
|
||||
options.env ?= process.env
|
||||
pathSegments = []
|
||||
nodeDirectoryPath = path.resolve(process.execPath, '..', '..', '..', '..', 'Resources')
|
||||
pathSegments.push(nodeDirectoryPath)
|
||||
pathSegments.push(options.env.PATH) if options.env.PATH
|
||||
options.env = _.extend({}, options.env, PATH: pathSegments.join(path.delimiter))
|
||||
|
||||
bufferStream: (stream, onLines, onDone) ->
|
||||
stream.setEncoding('utf8')
|
||||
buffered = ''
|
||||
|
||||
Reference in New Issue
Block a user