jakefile.js 2.0 KB

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