It is cold, but · we have Sake · and the hot spring
npm install sake-core --save-dev
Typically Sake is used via it's command line interface which can be installed
npm install -g sake-cli. Once the
sake command is
available, you can begin writing a
Sakefile and defining available tasks in
Optionally, you can write your Sakefile in CoffeeScript, which allows a very nice DSL-ish experience.
Async tasks are easy to declare, any task with an obvious callback will be
treated as asynchronous. Add an additional argument called
next and use it to indicate when your task is finished executing.
task 'compile:js''compile js'exec 'coffee -bc app.coffee'donetask 'minify:js''minify js'exec 'uglify-js --compress --mangle app.js > app.min.js'done
You can also return a promise from your task and sake will automatically
wait for it to resolve. Since
executive returns a promise, this works too:
task 'compile:js''compile js'->exec 'coffee -bc app.coffee'
You can manually invoke tasks and string them together with callbacks:
task 'build''build project'->invoke 'compile:js'->invoke 'minify:js'
Dependencies can be declared by adding an array of task names after your task's description.
task 'build''build project''compile:js''minify:js'
You can also pass an array of tasks
invoke and it will execute them in order
task 'build''build project'invoke 'compile:js''minify:js'done
...or more explicitly using
If you want to execute tasks in parallel you can use
task 'compile''compile css & js'invokeparallel 'compile:css''compile:js'done
You can check for running tasks using the
task 'watch''watch for changes and re-compile js'->exec 'coffee -bcmw -o lib/ src/'task 'watch:test''watch for changes and re-run tests'invoke 'watch'require'vigil'watch __dirnamereturn if running 'test'if /^test/test filenameinvoke 'test'test: filenameif /^src/test filenameinvoke 'test'
You can also use
yield to wait for the value of a promise and eschew the use
task 'compile:js''compile js'->yield exec 'coffee -bc app.coffee'task 'minify:js''minify js'->yield exec 'uglify-js --compress --mangle app.js > app.min.js'
This really pays dividends with more complicated tasks:
task 'package''Package project'->yield exec '''mkdir -p distrm -rf dist/*'''yield execparallel '''cp manifest.json distcp -rf assets distcp -rf lib distcp -rf views dist'''yield exec '''zip -r package.zip distrm -rf dist'''
You can upgrade any Cakefile into a Sakefile by requiring
sake-core at the top
of your Cakefile.
You can peruse Sake's Sakefile for a real world example.