| 1 | var fs = require('fs');
|
|---|
| 2 | var path = require('path');
|
|---|
| 3 | var execSync = require('child_process').execSync;
|
|---|
| 4 | var exec = function (cmd) {
|
|---|
| 5 | execSync(cmd, {stdio: 'inherit'});
|
|---|
| 6 | };
|
|---|
| 7 |
|
|---|
| 8 | /* global jake, task, desc, publishTask */
|
|---|
| 9 |
|
|---|
| 10 | task('build', ['lint', 'clean', 'browserify', 'minify'], function () {
|
|---|
| 11 | console.log('Build completed.');
|
|---|
| 12 | });
|
|---|
| 13 |
|
|---|
| 14 | desc('Cleans browerified/minified files and package files');
|
|---|
| 15 | task('clean', ['clobber'], function () {
|
|---|
| 16 | jake.rmRf('./ejs.js');
|
|---|
| 17 | jake.rmRf('./ejs.min.js');
|
|---|
| 18 | console.log('Cleaned up compiled files.');
|
|---|
| 19 | });
|
|---|
| 20 |
|
|---|
| 21 | desc('Lints the source code');
|
|---|
| 22 | task('lint', ['clean'], function () {
|
|---|
| 23 | var epath = path.join('./node_modules/.bin/eslint');
|
|---|
| 24 | exec(epath+' "**/*.js"');
|
|---|
| 25 | console.log('Linting completed.');
|
|---|
| 26 | });
|
|---|
| 27 |
|
|---|
| 28 | task('browserify', function () {
|
|---|
| 29 | var epath = path.join('./node_modules/browserify/bin/cmd.js');
|
|---|
| 30 | exec(epath+' --standalone ejs lib/ejs.js > ejs.js');
|
|---|
| 31 | console.log('Browserification completed.');
|
|---|
| 32 | });
|
|---|
| 33 |
|
|---|
| 34 | task('minify', function () {
|
|---|
| 35 | var epath = path.join('./node_modules/uglify-js/bin/uglifyjs');
|
|---|
| 36 | exec(epath+' ejs.js > ejs.min.js');
|
|---|
| 37 | console.log('Minification completed.');
|
|---|
| 38 | });
|
|---|
| 39 |
|
|---|
| 40 | desc('Generates the EJS API docs for the public API');
|
|---|
| 41 | task('doc', function () {
|
|---|
| 42 | jake.rmRf('out');
|
|---|
| 43 | var epath = path.join('./node_modules/.bin/jsdoc');
|
|---|
| 44 | exec(epath+' --verbose -c jsdoc.json lib/* docs/jsdoc/*');
|
|---|
| 45 | console.log('Documentation generated in ./out.');
|
|---|
| 46 | });
|
|---|
| 47 |
|
|---|
| 48 | desc('Generates the EJS API docs for the public and private API');
|
|---|
| 49 | task('devdoc', function () {
|
|---|
| 50 | jake.rmRf('out');
|
|---|
| 51 | var epath = path.join('./node_modules/.bin/jsdoc');
|
|---|
| 52 | exec(epath+' --verbose -p -c jsdoc.json lib/* docs/jsdoc/*');
|
|---|
| 53 | console.log('Documentation generated in ./out.');
|
|---|
| 54 | });
|
|---|
| 55 |
|
|---|
| 56 | desc('Publishes the EJS API docs');
|
|---|
| 57 | task('docPublish', ['doc'], function () {
|
|---|
| 58 | fs.writeFileSync('out/CNAME', 'api.ejs.co');
|
|---|
| 59 | console.log('Pushing docs to gh-pages...');
|
|---|
| 60 | var epath = path.join('./node_modules/.bin/git-directory-deploy');
|
|---|
| 61 | exec(epath+' --directory out/');
|
|---|
| 62 | console.log('Docs published to gh-pages.');
|
|---|
| 63 | });
|
|---|
| 64 |
|
|---|
| 65 | desc('Runs the EJS test suite');
|
|---|
| 66 | task('test', ['lint'], function () {
|
|---|
| 67 | exec(path.join('./node_modules/.bin/mocha --u tdd'));
|
|---|
| 68 | });
|
|---|
| 69 |
|
|---|
| 70 | publishTask('ejs', ['build'], function () {
|
|---|
| 71 | this.packageFiles.include([
|
|---|
| 72 | 'jakefile.js',
|
|---|
| 73 | 'README.md',
|
|---|
| 74 | 'LICENSE',
|
|---|
| 75 | 'package.json',
|
|---|
| 76 | 'ejs.js',
|
|---|
| 77 | 'ejs.min.js',
|
|---|
| 78 | 'lib/**',
|
|---|
| 79 | 'bin/**',
|
|---|
| 80 | 'usage.txt'
|
|---|
| 81 | ]);
|
|---|
| 82 | });
|
|---|
| 83 |
|
|---|
| 84 | jake.Task.publish.on('complete', function () {
|
|---|
| 85 | console.log('Updating hosted docs...');
|
|---|
| 86 | console.log('If this fails, run jake docPublish to re-try.');
|
|---|
| 87 | jake.Task.docPublish.invoke();
|
|---|
| 88 | });
|
|---|