mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-22 00:19:24 +03:00
Send remaining stdout/stderr output to callbacks
Previously this data was only sent to the done handlers and so commands such as SelectAllMatchesInProject were not displaying all the results when the result size was large.
This commit is contained in:
parent
4eff8b657f
commit
48bdc75359
@ -11,9 +11,17 @@ describe 'Child Processes', ->
|
||||
it "returns a promise that resolves to stdout and stderr", ->
|
||||
waitsForPromise ->
|
||||
cmd = "echo 'good' && echo 'bad' >&2"
|
||||
ChildProcess.exec(cmd).done (stdout, stderr) ->
|
||||
expect(stdout).toBe 'good\n'
|
||||
expect(stderr).toBe 'bad\n'
|
||||
standardOutput = ''
|
||||
errorOutput = ''
|
||||
options =
|
||||
stdout: (data) ->
|
||||
standardOutput += data
|
||||
stderr: (data) ->
|
||||
errorOutput += data
|
||||
|
||||
ChildProcess.exec(cmd, options).done ->
|
||||
expect(standardOutput).toBe 'good\n'
|
||||
expect(errorOutput).toBe 'bad\n'
|
||||
|
||||
describe "when options are given", ->
|
||||
it "calls the options.stdout callback when new data is received on stdout", ->
|
||||
@ -89,6 +97,10 @@ describe 'Child Processes', ->
|
||||
it "executes the callback with error set to the exit status", ->
|
||||
waitsForPromise shouldReject: true, ->
|
||||
cmd = "echo 'bad' >&2 && exit 2"
|
||||
ChildProcess.exec(cmd).fail (error) ->
|
||||
errorOutput = ''
|
||||
options =
|
||||
stderr: (data) ->
|
||||
errorOutput += data
|
||||
ChildProcess.exec(cmd, options).fail (error) ->
|
||||
expect(error.exitStatus).toBe 2
|
||||
expect(error.stderr).toBe "bad\n"
|
||||
expect(errorOutput).toBe "bad\n"
|
||||
|
@ -14,11 +14,13 @@ class ChildProccess
|
||||
options.stderr = @bufferLines(options.stderr) if options.stderr
|
||||
|
||||
$native.exec command, options, (exitStatus, stdout, stderr) ->
|
||||
options.stdout(stdout) if options.stdout
|
||||
options.stderr(stderr) if options.stderr
|
||||
try
|
||||
if exitStatus != 0
|
||||
deferred.reject({command, exitStatus, stderr})
|
||||
deferred.reject({command, exitStatus})
|
||||
else
|
||||
deferred.resolve(stdout, stderr)
|
||||
deferred.resolve()
|
||||
catch e
|
||||
console.error "In ChildProccess termination callback: ", e.message
|
||||
console.error e.stack
|
||||
|
Loading…
Reference in New Issue
Block a user