You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
1.9 KiB

  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', function () {
  18. exec('./node_modules/.bin/eslint "**/*.js" Jakefile');
  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. task('doc', function (dev) {
  30. jake.rmRf('out');
  31. var p = dev ? '-p' : '';
  32. exec('./node_modules/.bin/jsdoc ' + p + ' -c jsdoc.json lib/* docs/jsdoc/*');
  33. console.log('Documentation generated.');
  34. });
  35. task('docPublish', ['doc'], function () {
  36. fs.writeFileSync('out/CNAME', 'api.ejs.co');
  37. console.log('Pushing docs to gh-pages...');
  38. exec('./node_modules/.bin/git-directory-deploy --directory out/');
  39. console.log('Docs published to gh-pages.');
  40. });
  41. task('test', ['lint'], function () {
  42. exec('./node_modules/.bin/mocha');
  43. });
  44. publishTask('ejs', ['build'], function () {
  45. this.packageFiles.include([
  46. 'Jakefile',
  47. 'README.md',
  48. 'LICENSE',
  49. 'package.json',
  50. 'ejs.js',
  51. 'ejs.min.js',
  52. 'lib/**'
  53. ]);
  54. });
  55. jake.Task.publish.on('complete', function () {
  56. console.log('Updating hosted docs...');
  57. console.log('If this fails, run jake docPublish to re-try.');
  58. jake.Task.docPublish.invoke();
  59. });