twitst4tz

twitter statistics web application
Log | Files | Refs | README | LICENSE

jakefile.js (2033B)


      1 var fs = require('fs');
      2 var execSync = require('child_process').execSync;
      3 var exec = function (cmd) {
      4   execSync(cmd, {stdio: 'inherit'});
      5 };
      6 
      7 /* global jake, task, desc, publishTask */
      8 
      9 task('build', ['lint', 'clean', 'browserify', 'minify'], function () {
     10   console.log('Build completed.');
     11 });
     12 
     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.');
     18 });
     19 
     20 desc('Lints the source code');
     21 task('lint', ['clean'], function () {
     22   exec('./node_modules/.bin/eslint "**/*.js"');
     23   console.log('Linting completed.');
     24 });
     25 
     26 task('browserify', function () {
     27   exec('./node_modules/browserify/bin/cmd.js --standalone ejs lib/ejs.js > ejs.js');
     28   console.log('Browserification completed.');
     29 });
     30 
     31 task('minify', function () {
     32   exec('./node_modules/uglify-js/bin/uglifyjs ejs.js > ejs.min.js');
     33   console.log('Minification completed.');
     34 });
     35 
     36 desc('Generates the EJS API docs');
     37 task('doc', function (dev) {
     38   jake.rmRf('out');
     39   var p = dev ? '-p' : '';
     40   exec('./node_modules/.bin/jsdoc ' + p + ' -c jsdoc.json lib/* docs/jsdoc/*');
     41   console.log('Documentation generated.');
     42 });
     43 
     44 desc('Publishes the EJS API docs');
     45 task('docPublish', ['doc'], function () {
     46   fs.writeFileSync('out/CNAME', 'api.ejs.co');
     47   console.log('Pushing docs to gh-pages...');
     48   exec('./node_modules/.bin/git-directory-deploy --directory out/');
     49   console.log('Docs published to gh-pages.');
     50 });
     51 
     52 desc('Runs the EJS test suite');
     53 task('test', ['lint'], function () {
     54   exec('./node_modules/.bin/mocha');
     55 });
     56 
     57 publishTask('ejs', ['build'], function () {
     58   this.packageFiles.include([
     59     'jakefile.js',
     60     'README.md',
     61     'LICENSE',
     62     'package.json',
     63     'postinstall.js',
     64     'ejs.js',
     65     'ejs.min.js',
     66     'lib/**'
     67   ]);
     68 });
     69 
     70 jake.Task.publish.on('complete', function () {
     71   console.log('Updating hosted docs...');
     72   console.log('If this fails, run jake docPublish to re-try.');
     73   jake.Task.docPublish.invoke();
     74 });