123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 |
- # This file was originally created by Benjamin Lupton <b@lupton.cc> (http://balupton.com)
- # and is currently licensed under the Creative Commons Zero (http://creativecommons.org/publicdomain/zero/1.0/)
- # making it public domain so you can do whatever you wish with it without worry (you can even remove this notice!)
- #
- # If you change something here, be sure to reflect the changes in:
- # - the scripts section of the package.json file
- # - the .travis.yml file
- # -----------------
- # Variables
- WINDOWS = process.platform.indexOf('win') is 0
- NODE = process.execPath
- NPM = if WINDOWS then process.execPath.replace('node.exe','npm.cmd') else 'npm'
- EXT = (if WINDOWS then '.cmd' else '')
- APP = process.cwd()
- BIN = "#{APP}/node_modules/.bin"
- CAKE = "#{BIN}/cake#{EXT}"
- COFFEE = "#{BIN}/coffee#{EXT}"
- DOCPAD = "#{BIN}/docpad#{EXT}"
- UGLIFY = "#{BIN}/uglifyjs#{EXT}"
- OUT = "#{APP}/out"
- SRC = "#{APP}/src"
- BROWSERIFY = "#{BIN}/browserify#{EXT}"
- # -----------------
- # Requires
- pathUtil = require('path')
- {exec,spawn} = require('child_process')
- safe = (next,fn) ->
- return (err) ->
- return next(err) if err
- return fn()
- # -----------------
- # Actions
- bench = (opts,next) ->
- (next = opts; opts = {}) unless next?
- spawn(NODE, ["#{OUT}/test/benchmark.js"], {stdio:'inherit',cwd:APP}).on('close',next)
- clean = (opts,next) ->
- (next = opts; opts = {}) unless next?
- args = [
- '-Rf'
- OUT
- pathUtil.join(APP, 'node_modules')
- pathUtil.join(APP, '*out')
- pathUtil.join(APP, '*log')
- ]
- spawn('rm', args, {stdio:'inherit',cwd:APP}).on('close',next)
- browserify = (opts,next) ->
- (next = opts; opts = {}) unless next?
- spawn(
- BROWSERIFY,
- ["#{OUT}/lib/js2coffee.js", '-s', 'js2coffee', '-o', "#{OUT}/lib/browser.js"],
- {stdio:'inherit',cwd:APP}
- ).on('close',next)
- uglify = (opts,next) ->
- (next = opts; opts = {}) unless next?
- spawn(UGLIFY, ["#{OUT}/lib/browser.js", '-ms'], {stdio:'inherit',cwd:APP}).on('close',next)
- compile = (opts,next) ->
- (next = opts; opts = {}) unless next?
- spawn(DOCPAD, ['generate'], {stdio:'inherit',cwd:APP}).on('close',next)
- watch = (opts,next) ->
- (next = opts; opts = {}) unless next?
- spawn(DOCPAD, ['watch'], {stdio:'inherit',cwd:APP}).on('close',next)
- install = (opts,next) ->
- (next = opts; opts = {}) unless next?
- spawn(NPM, ['install'], {stdio:'inherit',cwd:APP}).on('close',next)
- reset = (opts,next) ->
- (next = opts; opts = {}) unless next?
- clean opts, safe next, -> install opts, safe next, -> compile opts, next
- setup = (opts,next) ->
- (next = opts; opts = {}) unless next?
- install opts, safe next, ->
- compile opts, next
- test = (opts,next) ->
- (next = opts; opts = {}) unless next?
- args = []
- args.push("--debug-brk") if opts.debug
- args.push("#{OUT}/test/everything.js")
- spawn(NODE, args, {stdio:'inherit',cwd:APP}, next)
- finish = (err) ->
- throw err if err
- console.log('OK')
- # -----------------
- # Commands
- # bench
- task 'bench', 'benchmark our project', ->
- bench finish
- # clean
- task 'clean', 'clean up instance', ->
- clean finish
- # compile
- task 'compile', 'compile our files', ->
- compile finish
- # browserify
- task 'browserify', 'browserify', ->
- browserify finish
- # uglify
- task 'uglify', 'minify browser.js and dump to stdout', ->
- uglify ->
- # dev/watch
- task 'dev', 'watch and recompile our files', ->
- watch finish
- task 'watch', 'watch and recompile our files', ->
- watch finish
- # install
- task 'install', 'install dependencies', ->
- install finish
- # reset
- task 'reset', 'reset instance', ->
- reset finish
- # setup
- task 'setup', 'setup for development', ->
- setup finish
- # test
- task 'test', 'run our tests', ->
- test finish
- # test-debug
- task 'test-debug', 'run our tests in debug mode', ->
- test {debug:true}, finish
- # test-prepare
- task 'test-prepare', 'prepare out tests', ->
- setup finish
|