500px / gunter

Language agnostic task wrapper and loyal servant.
MIT License
9 stars 1 forks source link

Async localTask and remoteTask #1

Closed devonoel closed 9 years ago

devonoel commented 9 years ago

I really lazily implemented two of .exec's private function, localTask and remoteTask, which take care of running commands locally and against some server respectively.

They're implemented synchronously, meaning that Gunter will wait around for a task to finish before .exec eventually returns either false if it errors or the task object that was executed if successful.

Instead, they should be implemented asynchronously, since this is the whole reason I implemented this as a Node.js package instead of some Sinatra API or something. They should execute tasks in the background, and call some callback function when complete, of the form callback(error, task), where callback(error) is called if there's an error, and callback(null, task) is called if the task is executed with no errors.

devonoel commented 9 years ago

This is solved in branch async-exec, though the branch is still in development, and brings up another issue: how to actually handle the completion of a task execution (and for that matter, how to capture and communicate stdout from the task executing).

devonoel commented 9 years ago

Gonna go with an EventEmitter here. It can handle both task completion, and individual command completion elegantly. Gunter will export an emitter object that client's can use to listen for events emitted by exec to communicate its state.