Add BufferedNodeProcess to execute apm and nak.

On Windows the shebang string is not supported, so we haveto execute apm
and nak as scripts instead of as executables.
This commit is contained in:
Cheng Zhao
2013-08-10 15:33:55 +08:00
parent ebaa6c349f
commit 66da13a6ff
3 changed files with 27 additions and 6 deletions

View File

@@ -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 ###

View File

@@ -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)
@@ -59,7 +59,7 @@ install = ({name, version}, callback) ->
actom.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}

View 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})