gulpfile.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /* eslint max-nested-callbacks: 0 */
  2. 'use strict';
  3. var eslint = require('gulp-eslint');
  4. var exec = require('child_process').exec;
  5. var gulp = require('gulp');
  6. var jsonEditor = require('gulp-json-editor');
  7. var path = require('path');
  8. var util = require('util');
  9. function execCb(cb, err, stdout, stderr) {
  10. console.log(stdout);
  11. console.error(stderr);
  12. cb(err);
  13. }
  14. var options = {
  15. coveragePaths: [
  16. '*.js',
  17. 'lib/**/*.js',
  18. 'plugins/*.js'
  19. ],
  20. lintPaths: [
  21. '*.js',
  22. 'lib/**/*.js',
  23. 'plugins/*.js',
  24. 'templates/default/*.js',
  25. 'templates/haruki/*.js',
  26. 'test/specs/**/*.js'
  27. ],
  28. nodeBin: path.resolve(__dirname, './jsdoc.js'),
  29. nodePath: process.execPath
  30. };
  31. gulp.task('bump', function() {
  32. gulp.src('./package.json')
  33. .pipe(jsonEditor({
  34. revision: String( Date.now() )
  35. }))
  36. .pipe(gulp.dest('./'));
  37. });
  38. gulp.task('coverage', function(cb) {
  39. var cmd = util.format('./node_modules/.bin/nyc --reporter=html %s -T', options.nodeBin);
  40. exec(cmd, execCb.bind(null, cb));
  41. });
  42. gulp.task('lint', function() {
  43. return gulp.src(options.lintPaths)
  44. .pipe(eslint())
  45. .pipe(eslint.formatEach())
  46. .pipe(eslint.failOnError());
  47. });
  48. gulp.task('test', function(cb) {
  49. var cmd = util.format('%s "%s" -T', options.nodePath, options.nodeBin);
  50. exec(cmd, execCb.bind(null, cb));
  51. });
  52. gulp.task('default', ['lint', 'test']);