Created
January 28, 2013 17:18
-
-
Save stengland/4657330 to your computer and use it in GitHub Desktop.
Simple CoffeeScript Cakefile with a "build" task (cribbed from the CoffeScript wiki) and "spec" task that runs jasmine-node.
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
| fs = require 'fs' | |
| {exec} = require 'child_process' | |
| appFiles = [ | |
| # omit src/ and .coffee to make the below lines a little shorter | |
| 'app' | |
| 'models/thing' | |
| 'view/window' | |
| ] | |
| task 'build', 'Build single application file from source files', -> | |
| appContents = new Array remaining = appFiles.length | |
| for file, index in appFiles then do (file, index) -> | |
| fs.readFile "src/#{file}.coffee", 'utf8', (err, fileContents) -> | |
| throw err if err | |
| appContents[index] = fileContents | |
| process() if --remaining is 0 | |
| process = -> | |
| fs.writeFile 'lib/app.coffee', appContents.join('\n\n'), 'utf8', (err) -> | |
| throw err if err | |
| exec 'coffee --compile lib/app.coffee', (err, stdout, stderr) -> | |
| throw err if err | |
| console.log stdout + stderr | |
| fs.unlink 'lib/app.coffee', (err) -> | |
| throw err if err | |
| console.log 'Done.' | |
| task 'spec', 'Run jasmine specs', -> | |
| exec 'jasmine-node --coffee spec', (err, stdout, stderr) -> | |
| console.log stdout + stderr |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment