Skip to content

Instantly share code, notes, and snippets.

@mizchi
Forked from anonymous/simple_grunt_task.coffee
Created February 26, 2013 03:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mizchi/5035602 to your computer and use it in GitHub Desktop.
Save mizchi/5035602 to your computer and use it in GitHub Desktop.
# in gruntfile.coffee
{exec} = require('child_process')
runCommand = (exp, done) ->
exec exp, (error, stdout, stderr) ->
return done(true) if error or stderr
done(false,stdout)
grunt.registerMultiTask 'test', 'test command', ->
conf = @
done = conf.async()
{src, dest} = conf.data.file
runCommand 'ls -l', (error, ret) =>
if error
grunt.log.writeln('File "' + dest + '" failed.')
return done(false)
grunt.log.writeln('File "' + ret + '" created.');
done(true)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment