@@ -247,7 +247,7 @@ public protocol TaskEventType {
247247/// Represents events that can occur during the execution of a task that is
248248/// expected to terminate with a result of type T (upon success).
249249public enum TaskEvent < T> : TaskEventType {
250- /// The task was launched.
250+ /// The task is about to be launched.
251251 case Launch( Task )
252252
253253 /// Some data arrived from the task on `stdout`.
@@ -377,35 +377,35 @@ extension Signal where Value: TaskEventType {
377377/// Launches a new shell task.
378378///
379379/// - Parameters:
380- /// - taskDescription: The task to launch.
381- /// - standardInput: Data to stream to standard input of the launched process. If nil, stdin will
382- /// be inherited from the parent process.
380+ /// - task: The task to launch.
381+ /// - standardInput: Data to stream to standard input of the launched process. If nil, stdin will
382+ /// be inherited from the parent process.
383383///
384384/// - Returns: A producer that will launch the task when started, then send
385385/// `TaskEvent`s as execution proceeds.
386- public func launchTask( taskDescription : Task , standardInput: SignalProducer < NSData , NoError > ? = nil ) -> SignalProducer < TaskEvent < NSData > , TaskError > {
386+ public func launchTask( task : Task , standardInput: SignalProducer < NSData , NoError > ? = nil ) -> SignalProducer < TaskEvent < NSData > , TaskError > {
387387 return SignalProducer { observer, disposable in
388- let queue = dispatch_queue_create ( taskDescription . description, DISPATCH_QUEUE_SERIAL)
388+ let queue = dispatch_queue_create ( task . description, DISPATCH_QUEUE_SERIAL)
389389 let group = Task . group
390390
391- let task = NSTask ( )
392- task . launchPath = taskDescription . launchPath
393- task . arguments = taskDescription . arguments
391+ let rawTask = NSTask ( )
392+ rawTask . launchPath = task . launchPath
393+ rawTask . arguments = task . arguments
394394
395- if let cwd = taskDescription . workingDirectoryPath {
396- task . currentDirectoryPath = cwd
395+ if let cwd = task . workingDirectoryPath {
396+ rawTask . currentDirectoryPath = cwd
397397 }
398398
399- if let env = taskDescription . environment {
400- task . environment = env
399+ if let env = task . environment {
400+ rawTask . environment = env
401401 }
402402
403403 var stdinProducer : SignalProducer < ( ) , TaskError > = . empty
404404
405405 if let input = standardInput {
406406 switch Pipe . create ( queue, group) {
407407 case let . Success( pipe) :
408- task . standardInput = pipe. readHandle
408+ rawTask . standardInput = pipe. readHandle
409409
410410 stdinProducer = pipe. writeDataFromProducer ( input) . on ( started: {
411411 close ( pipe. readFD)
@@ -460,11 +460,11 @@ public func launchTask(taskDescription: Task, standardInput: SignalProducer<NSDa
460460 ) )
461461 }
462462
463- task . standardOutput = stdoutPipe. writeHandle
464- task . standardError = stderrPipe. writeHandle
463+ rawTask . standardOutput = stdoutPipe. writeHandle
464+ rawTask . standardError = stderrPipe. writeHandle
465465
466466 dispatch_group_enter ( group)
467- task . terminationHandler = { task in
467+ rawTask . terminationHandler = { task in
468468 let terminationStatus = task. terminationStatus
469469 if terminationStatus == EXIT_SUCCESS {
470470 // Wait for stderr to finish, then pass
@@ -486,8 +486,9 @@ public func launchTask(taskDescription: Task, standardInput: SignalProducer<NSDa
486486 }
487487 dispatch_group_leave ( group)
488488 }
489-
490- task. launch ( )
489+
490+ observer. sendNext ( . Launch( task) )
491+ rawTask. launch ( )
491492 close ( stdoutPipe. writeFD)
492493 close ( stderrPipe. writeFD)
493494
@@ -496,7 +497,7 @@ public func launchTask(taskDescription: Task, standardInput: SignalProducer<NSDa
496497 }
497498
498499 disposable. addDisposable {
499- task . terminate ( )
500+ rawTask . terminate ( )
500501 }
501502 }
502503 }
0 commit comments