1 var fs = require('fs');
2 var execSync = require('child_process').execSync;
3 var exec = function (cmd) {
4 execSync(cmd, {stdio: 'inherit'});
7 /* global jake, task, desc, publishTask */
9 task('build', ['lint', 'clean', 'browserify', 'minify'], function () {
10 console.log('Build completed.');
13 desc('Cleans browerified/minified files and package files');
14 task('clean', ['clobber'], function () {
15 jake.rmRf('./ejs.js');
16 jake.rmRf('./ejs.min.js');
17 console.log('Cleaned up compiled files.');
20 desc('Lints the source code');
21 task('lint', function () {
22 exec('./node_modules/.bin/eslint "**/*.js" Jakefile');
23 console.log('Linting completed.');
26 task('browserify', function () {
27 exec('./node_modules/browserify/bin/cmd.js --standalone ejs lib/ejs.js > ejs.js');
28 console.log('Browserification completed.');
31 task('minify', function () {
32 exec('./node_modules/uglify-js/bin/uglifyjs ejs.js > ejs.min.js');
33 console.log('Minification completed.');
36 task('doc', function (dev) {
38 var p = dev ? '-p' : '';
39 exec('./node_modules/.bin/jsdoc ' + p + ' -c jsdoc.json lib/* docs/jsdoc/*');
40 console.log('Documentation generated.');
43 task('docPublish', ['doc'], function () {
44 fs.writeFileSync('out/CNAME', 'api.ejs.co');
45 console.log('Pushing docs to gh-pages...');
46 exec('./node_modules/.bin/git-directory-deploy --directory out/');
47 console.log('Docs published to gh-pages.');
50 task('test', ['lint'], function () {
51 exec('./node_modules/.bin/mocha');
54 publishTask('ejs', ['build'], function () {
55 this.packageFiles.include([
66 jake.Task.publish.on('complete', function () {
67 console.log('Updating hosted docs...');
68 console.log('If this fails, run jake docPublish to re-try.');
69 jake.Task.docPublish.invoke();