mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Merge pull request #697 from github/buffered-node-process
Remove dependency of bundled node
This commit is contained in:
@@ -5,7 +5,7 @@ cd "$(dirname "${BASH_SOURCE[0]}" )/.."
|
||||
TARGET=${1:-atom-shell}
|
||||
DISTURL="https://gh-contractor-zcbenz.s3.amazonaws.com/atom-shell"
|
||||
CURRENT_VERSION=$(cat "${TARGET}/version" 2>&1)
|
||||
LATEST_VERSION=ea1f81aa5260fe2d4a844f18e0251278fbadc093 # v0.2.1
|
||||
LATEST_VERSION=$(curl -fsSkL $DISTURL/version)
|
||||
|
||||
if [ -z "${LATEST_VERSION}" ] ; then
|
||||
echo "Could determine lastest version of atom-shell" >&2
|
||||
|
||||
@@ -7,7 +7,7 @@ Buffer = require 'text-buffer'
|
||||
EditSession = require 'edit-session'
|
||||
EventEmitter = require 'event-emitter'
|
||||
Directory = require 'directory'
|
||||
BufferedProcess = require 'buffered-process'
|
||||
BufferedNodeProcess = require 'buffered-node-process'
|
||||
|
||||
# Public: Represents a project that's opened in Atom.
|
||||
#
|
||||
@@ -292,7 +292,7 @@ class Project
|
||||
ignoredNames = config.get('core.ignoredNames') ? []
|
||||
args.unshift('--ignore', ignoredNames.join(',')) if ignoredNames.length > 0
|
||||
args.unshift('--addVCSIgnores') if config.get('core.excludeVcsIgnoredPaths')
|
||||
new BufferedProcess({command, args, stdout, stderr, exit})
|
||||
new BufferedNodeProcess({command, args, stdout, stderr, exit})
|
||||
deferred
|
||||
|
||||
### Internal ###
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
BufferedProcess = require 'buffered-process'
|
||||
BufferedNodeProcess = require 'buffered-node-process'
|
||||
roaster = require 'roaster'
|
||||
async = require 'async'
|
||||
|
||||
@@ -41,7 +41,7 @@ getAvailable = (callback) ->
|
||||
else
|
||||
callback(new Error("apm failed with code: #{code}"))
|
||||
|
||||
new BufferedProcess({command, args, stdout, exit})
|
||||
new BufferedNodeProcess({command, args, stdout, exit})
|
||||
|
||||
install = ({name, version}, callback) ->
|
||||
activateOnSuccess = !atom.isPackageDisabled(name)
|
||||
@@ -56,10 +56,10 @@ install = ({name, version}, callback) ->
|
||||
atom.activatePackage(name) if activateOnSuccess
|
||||
callback()
|
||||
else
|
||||
actom.activatePackage(name) if activateOnFailure
|
||||
atom.activatePackage(name) if activateOnFailure
|
||||
callback(new Error("Installing '#{name}' failed."))
|
||||
|
||||
new BufferedProcess({command, args, exit})
|
||||
new BufferedNodeProcess({command, args, exit})
|
||||
|
||||
uninstall = ({name}, callback) ->
|
||||
atom.deactivatePackage(name) if atom.isPackageActive(name)
|
||||
@@ -73,6 +73,6 @@ uninstall = ({name}, callback) ->
|
||||
else
|
||||
callback(new Error("Uninstalling '#{name}' failed."))
|
||||
|
||||
new BufferedProcess({command, args, exit})
|
||||
new BufferedNodeProcess({command, args, exit})
|
||||
|
||||
module.exports = {renderMarkdownInMetadata, install, uninstall, getAvailable}
|
||||
|
||||
21
src/stdlib/buffered-node-process.coffee
Normal file
21
src/stdlib/buffered-node-process.coffee
Normal file
@@ -0,0 +1,21 @@
|
||||
BufferedProcess = require 'buffered-process'
|
||||
path = require 'path'
|
||||
|
||||
# Like BufferedProcess, but accepts a node script instead of an executable,
|
||||
# on Unix which allows running scripts and executables, this seems unnecessary,
|
||||
# but on Windows we have to separate scripts from executables since it doesn't
|
||||
# support shebang strings.
|
||||
module.exports =
|
||||
class BufferedNodeProcess extends BufferedProcess
|
||||
constructor: ({command, args, options, stdout, stderr, exit}) ->
|
||||
args = ['--atom-child_process-fork', command].concat(args)
|
||||
node =
|
||||
if process.platform is 'darwin'
|
||||
# On OS X we use the helper process to run script, because it doesn't
|
||||
# create an icon on the Dock.
|
||||
path.resolve(process.resourcesPath, '..', 'Frameworks',
|
||||
'Atom Helper.app', 'Contents', 'MacOS', 'Atom Helper')
|
||||
else
|
||||
process.execPath
|
||||
|
||||
super({command: node, args, options, stdout, stderr, exit})
|
||||
@@ -9,7 +9,6 @@ class BufferedProcess
|
||||
|
||||
constructor: ({command, args, options, stdout, stderr, exit}={}) ->
|
||||
options ?= {}
|
||||
@addNodeDirectoryToPath(options)
|
||||
@process = ChildProcess.spawn(command, args, options)
|
||||
|
||||
stdoutClosed = true
|
||||
@@ -40,14 +39,6 @@ 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 = ''
|
||||
|
||||
2
vendor/apm
vendored
2
vendor/apm
vendored
Submodule vendor/apm updated: 1cda00c850...c2b8158563
Reference in New Issue
Block a user