Skip to content

Commit

Permalink
yalla
Browse files Browse the repository at this point in the history
  • Loading branch information
Radagaisus committed Jul 19, 2013
1 parent 4fef382 commit 6298207
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 0 deletions.
40 changes: 40 additions & 0 deletions Cakefile
@@ -0,0 +1,40 @@
{spawn, exec} = require 'child_process'

task 'build', ->
run 'coffee -c *.coffee test/**/*.coffee'

# run spawns a bash process, sends it a
# command and hooks its stdout and sterr
# to the current process. We use this in
# our Cakefile.
#
# Parameters are used based on their type:
# - string - is the command
# - object - options passed to spawn
# - array - joined with spaces to form a
# command
# - function - callback to invoke if the
# process completed successfully
#
# Usage:
# run "echo hi", ->
# run "echo bye"
# > hi
# > bye
#
module.exports = run = (args...) ->
for a in args
switch typeof a
when 'string' then command = a
when 'object'
if a instanceof Array then params = a
else options = a
when 'function' then callback = a

command += ' ' + params.join ' ' if params?
cmd = spawn '/bin/sh', ['-c', command], options
cmd.stdout.on 'data', (data) -> process.stdout.write data
cmd.stderr.on 'data', (data) -> process.stderr.write data
process.on 'SIGHUP', -> cmd.kill()
cmd.on 'exit', (code) -> callback() if callback? and code is 0

24 changes: 24 additions & 0 deletions index.js

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

6 changes: 6 additions & 0 deletions test/example/hello.js

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

6 changes: 6 additions & 0 deletions test/example/hi.js

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

0 comments on commit 6298207

Please sign in to comment.