Fall back to system root for cmd.exe path
Esse commit está contido em:
@@ -1,5 +1,6 @@
|
|||||||
BufferedProcess = require '../src/buffered-process'
|
|
||||||
ChildProcess = require 'child_process'
|
ChildProcess = require 'child_process'
|
||||||
|
path = require 'path'
|
||||||
|
BufferedProcess = require '../src/buffered-process'
|
||||||
|
|
||||||
describe "BufferedProcess", ->
|
describe "BufferedProcess", ->
|
||||||
describe "when a bad command is specified", ->
|
describe "when a bad command is specified", ->
|
||||||
@@ -42,7 +43,7 @@ describe "BufferedProcess", ->
|
|||||||
expect(window.onerror.mostRecentCall.args[0]).toContain 'Failed to spawn command `bad-command-nope`'
|
expect(window.onerror.mostRecentCall.args[0]).toContain 'Failed to spawn command `bad-command-nope`'
|
||||||
expect(window.onerror.mostRecentCall.args[4].name).toBe 'BufferedProcessError'
|
expect(window.onerror.mostRecentCall.args[4].name).toBe 'BufferedProcessError'
|
||||||
|
|
||||||
describe "when the explorer command is spawned on Windows", ->
|
describe "on Windows", ->
|
||||||
originalPlatform = null
|
originalPlatform = null
|
||||||
|
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
@@ -61,6 +62,14 @@ describe "BufferedProcess", ->
|
|||||||
afterEach ->
|
afterEach ->
|
||||||
Object.defineProperty process, 'platform', value: originalPlatform
|
Object.defineProperty process, 'platform', value: originalPlatform
|
||||||
|
|
||||||
it "doesn't quote arguments of the form /root,C...", ->
|
describe "when the explorer command is spawned on Windows", ->
|
||||||
new BufferedProcess({command: 'explorer.exe', args: ['/root,C:\\foo']})
|
it "doesn't quote arguments of the form /root,C...", ->
|
||||||
expect(ChildProcess.spawn.argsForCall[0][1][2]).toBe '"explorer.exe /root,C:\\foo"'
|
new BufferedProcess({command: 'explorer.exe', args: ['/root,C:\\foo']})
|
||||||
|
expect(ChildProcess.spawn.argsForCall[0][1][2]).toBe '"explorer.exe /root,C:\\foo"'
|
||||||
|
|
||||||
|
it "spawns the command using a cmd.exe wrapper", ->
|
||||||
|
new BufferedProcess({command: 'dir'})
|
||||||
|
expect(path.basename(ChildProcess.spawn.argsForCall[0][0])).toBe 'cmd.exe'
|
||||||
|
expect(ChildProcess.spawn.argsForCall[0][1][0]).toBe '/s'
|
||||||
|
expect(ChildProcess.spawn.argsForCall[0][1][1]).toBe '/c'
|
||||||
|
expect(ChildProcess.spawn.argsForCall[0][1][2]).toBe '"dir"'
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ class BufferedProcess
|
|||||||
cmdArgs = ['/s', '/c', "\"#{cmdArgs.join(' ')}\""]
|
cmdArgs = ['/s', '/c', "\"#{cmdArgs.join(' ')}\""]
|
||||||
cmdOptions = _.clone(options)
|
cmdOptions = _.clone(options)
|
||||||
cmdOptions.windowsVerbatimArguments = true
|
cmdOptions.windowsVerbatimArguments = true
|
||||||
@process = ChildProcess.spawn(process.env.comspec or 'cmd.exe', cmdArgs, cmdOptions)
|
@process = ChildProcess.spawn(@getCmdPath(), cmdArgs, cmdOptions)
|
||||||
else
|
else
|
||||||
@process = ChildProcess.spawn(command, args, options)
|
@process = ChildProcess.spawn(command, args, options)
|
||||||
@killed = false
|
@killed = false
|
||||||
@@ -199,6 +199,14 @@ class BufferedProcess
|
|||||||
else
|
else
|
||||||
false
|
false
|
||||||
|
|
||||||
|
getCmdPath: ->
|
||||||
|
if process.env.comspec
|
||||||
|
process.env.compec
|
||||||
|
else if process.env.SystemRoot
|
||||||
|
path.join(process.env.SystemRoot, 'System32', 'cmd.exe')
|
||||||
|
else
|
||||||
|
'cmd.exe'
|
||||||
|
|
||||||
# Public: Terminate the process.
|
# Public: Terminate the process.
|
||||||
kill: ->
|
kill: ->
|
||||||
return if @killed
|
return if @killed
|
||||||
|
|||||||
Referência em uma Nova Issue
Bloquear um usuário