// Generated by CoffeeScript 1.6.3 var APP, BIN, BROWSERIFY, CAKE, COFFEE, DOCPAD, EXT, NODE, NPM, OUT, SRC, WINDOWS, bench, browserify, clean, compile, exec, finish, install, pathUtil, reset, safe, setup, spawn, test, watch, _ref; WINDOWS = process.platform.indexOf('win') === 0; NODE = process.execPath; NPM = WINDOWS ? process.execPath.replace('node.exe', 'npm.cmd') : 'npm'; EXT = (WINDOWS ? '.cmd' : ''); APP = process.cwd(); BIN = "" + APP + "/node_modules/.bin"; CAKE = "" + BIN + "/cake" + EXT; COFFEE = "" + BIN + "/coffee" + EXT; DOCPAD = "" + BIN + "/docpad" + EXT; OUT = "" + APP + "/out"; SRC = "" + APP + "/src"; BROWSERIFY = "" + BIN + "/browserify" + EXT; pathUtil = require('path'); _ref = require('child_process'), exec = _ref.exec, spawn = _ref.spawn; safe = function(next, fn) { return function(err) { if (err) { return next(err); } return fn(); }; }; bench = function(opts, next) { if (next == null) { next = opts; opts = {}; } return spawn(NODE, ["" + OUT + "/test/benchmark.js"], { stdio: 'inherit', cwd: APP }).on('close', next); }; clean = function(opts, next) { var args; if (next == null) { next = opts; opts = {}; } args = ['-Rf', OUT, pathUtil.join(APP, 'node_modules'), pathUtil.join(APP, '*out'), pathUtil.join(APP, '*log')]; return spawn('rm', args, { stdio: 'inherit', cwd: APP }).on('close', next); }; browserify = function(opts, next) { if (next == null) { next = opts; opts = {}; } return spawn(BROWSERIFY, ["" + OUT + "/lib/js2coffee.js", '-s', 'js2coffee', '-o', "" + OUT + "/lib/browser.js"], { stdio: 'inherit', cwd: APP }).on('close', next); }; compile = function(opts, next) { if (next == null) { next = opts; opts = {}; } return spawn(DOCPAD, ['generate'], { stdio: 'inherit', cwd: APP }).on('close', next); }; watch = function(opts, next) { if (next == null) { next = opts; opts = {}; } return spawn(DOCPAD, ['watch'], { stdio: 'inherit', cwd: APP }).on('close', next); }; install = function(opts, next) { if (next == null) { next = opts; opts = {}; } return spawn(NPM, ['install'], { stdio: 'inherit', cwd: APP }).on('close', next); }; reset = function(opts, next) { if (next == null) { next = opts; opts = {}; } return clean(opts, safe(next, function() { return install(opts, safe(next, function() { return compile(opts, safe(next, function() { return browserify(opts, next); })); })); })); }; setup = function(opts, next) { if (next == null) { next = opts; opts = {}; } return install(opts, safe(next, function() { return compile(opts, safe(next, function() { return browserify(opts, next); })); })); }; test = function(opts, next) { var args; if (next == null) { next = opts; opts = {}; } args = []; if (opts.debug) { args.push("--debug-brk"); } args.push("" + OUT + "/test/everything.js"); return spawn(NODE, args, { stdio: 'inherit', cwd: APP }, next); }; finish = function(err) { if (err) { throw err; } return console.log('OK'); }; task('bench', 'benchmark our project', function() { return bench(finish); }); task('clean', 'clean up instance', function() { return clean(finish); }); task('compile', 'compile our files', function() { return compile(browserify(finish)); }); task('dev', 'watch and recompile our files', function() { return watch(browserify(finish)); }); task('watch', 'watch and recompile our files', function() { return watch(browserify(finish)); }); task('install', 'install dependencies', function() { return install(finish); }); task('reset', 'reset instance', function() { return reset(finish); }); task('setup', 'setup for development', function() { return setup(finish); }); task('test', 'run our tests', function() { return test(finish); }); task('test-debug', 'run our tests in debug mode', function() { return test({ debug: true }, finish); }); task('test-prepare', 'prepare out tests', function() { return setup(finish); });