jakefile.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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 for the public API');
  30. task('doc', function () {
  31. jake.rmRf('out');
  32. exec('./node_modules/.bin/jsdoc --verbose -c jsdoc.json lib/* docs/jsdoc/*');
  33. console.log('Documentation generated in ./out.');
  34. });
  35. desc('Generates the EJS API docs for the public and private API');
  36. task('devdoc', function () {
  37. jake.rmRf('out');
  38. exec('./node_modules/.bin/jsdoc --verbose -p -c jsdoc.json lib/* docs/jsdoc/*');
  39. console.log('Documentation generated in ./out.');
  40. });
  41. desc('Publishes the EJS API docs');
  42. task('docPublish', ['doc'], function () {
  43. fs.writeFileSync('out/CNAME', 'api.ejs.co');
  44. console.log('Pushing docs to gh-pages...');
  45. exec('./node_modules/.bin/git-directory-deploy --directory out/');
  46. console.log('Docs published to gh-pages.');
  47. });
  48. desc('Runs the EJS test suite');
  49. task('test', ['lint'], function () {
  50. exec('./node_modules/.bin/mocha');
  51. });
  52. publishTask('ejs', ['build'], function () {
  53. this.packageFiles.include([
  54. 'jakefile.js',
  55. 'README.md',
  56. 'LICENSE',
  57. 'package.json',
  58. 'ejs.js',
  59. 'ejs.min.js',
  60. 'lib/**',
  61. 'bin/**',
  62. 'usage.txt'
  63. ]);
  64. });
  65. jake.Task.publish.on('complete', function () {
  66. console.log('Updating hosted docs...');
  67. console.log('If this fails, run jake docPublish to re-try.');
  68. jake.Task.docPublish.invoke();
  69. });