Created
March 20, 2012 18:17
-
-
Save BaseCase/2139106 to your computer and use it in GitHub Desktop.
A sample Cakefile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{exec} = require 'child_process' | |
task 'test', 'Runs all Jasmine specs in spec/ folder', -> | |
test() | |
task 'compile', 'Compiles coffee in src/ to js in bin/', -> | |
compile() | |
task 'stitch', 'Stitches all app .js files', -> | |
stitch() | |
task 'compress', 'Runs UglifyJS on stitched file in order to compress it', -> | |
compress() | |
task 'build', 'Does the full build magic', -> | |
test -> compile -> stitch -> compress() | |
task 'develop', 'Only compile and stitch, don\'t test or compress', -> | |
compile -> stitch() | |
test = (callback) -> | |
console.log "Running Jasmine specs" | |
exec 'jasmine-node --coffee spec/', (err, stdout, stderr) => | |
console.log stdout + stderr | |
# hack to work around jasmine-node's bad return vals: | |
throw "Tests fail. Build fails. You fail." if ~stdout.indexOf "Expected" | |
callback?() | |
compile = (callback) -> | |
exec 'coffee -o bin/ -c src/', (err, stdout, stderr) -> | |
throw err if err | |
console.log "Compiled coffee files" | |
callback?() | |
stitch = (callback) -> | |
stitch = require 'stitch' | |
fs = require 'fs' | |
myPackage = stitch.createPackage paths: [__dirname + '/bin', __dirname + '/vendor'] | |
myPackage.compile (err, source) -> | |
fs.writeFile 'app.js', source, (err) -> | |
throw err if err | |
console.log "Stitched js files" | |
callback?() | |
compress = (callback) -> | |
exec 'uglifyjs --overwrite app.js', (err, stdout, stderr) -> | |
throw err if err | |
console.log "Compressed app.js" | |
callback?() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment