jakefile.js 2.5 KB

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