Skip to content

Commit

Permalink
Exec: Add options param like real node exec.
Browse files Browse the repository at this point in the history
  • Loading branch information
ryan-roemer committed Jul 10, 2012
1 parent e47f86c commit 219b741
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
11 changes: 9 additions & 2 deletions cakepop.coffee
Expand Up @@ -80,11 +80,18 @@ class Utils
# Exec with log hooks to stdout, stderr.
#
# @param [String] cmd Command and arguments.
# @param [Object] [opts] (Optional) options.
# @param [Function] callback Callback on process end (printCallback).
#
@exec: (cmd, callback = @printCallback) =>
@exec: (allArgs...) =>
# Manually unpack arguments.
argsLen = allArgs.length
cmd = allArgs[0]
opts = if argsLen is 3 then allArgs[1] else {}
callback = allArgs[argsLen - 1] ? @printCallback

@print cmd
child_proc.exec cmd, (error, stdout, stderr) ->
child_proc.exec cmd, opts, (error, stdout, stderr) ->
process.stderr.write stderr if stderr
callback error, stdout.toString()

Expand Down
13 changes: 8 additions & 5 deletions cakepop.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 219b741

Please sign in to comment.