Gulpfile.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. "use strict";
  2. var gulp = require("gulp"),
  3. fs = require("fs"),
  4. cp = require("child_process"),
  5. jshint = require("gulp-jshint");
  6. // JSHint
  7. // https://github.com/wearefractal/gulp-jshint
  8. gulp.task("jshint", function () {
  9. //
  10. // FIXME
  11. //
  12. // gulp.jshint not reading .jshintrc
  13. // side-effect of JSHint itself not read configuration when using stdin
  14. //
  15. // https://github.com/wearefractal/gulp-jshint/issues/4
  16. //
  17. var options = JSON.parse(fs.readFileSync(".jshintrc", "utf8"));
  18. //
  19. // FIXME
  20. //
  21. // Can't use following due to Error: EMFILE, too many open files:
  22. //
  23. // gulp.src("./**/*.js")
  24. // .pipe(ignore({
  25. // pattern: [
  26. // "./node_modules/**",
  27. // "./test/temp/**"]}))
  28. //
  29. // Must wait for core impl of .src() ignores
  30. //
  31. // https://github.com/wearefractal/gulp/issues/35
  32. //
  33. gulp.src("./*.js")
  34. .pipe(jshint(options))
  35. .pipe(jshint.reporter("default"));
  36. gulp.src("./test/**/*.js")
  37. .pipe(jshint(options))
  38. .pipe(jshint.reporter("default"));
  39. });
  40. // default task
  41. gulp.task("default", function () {
  42. gulp.run("jshint");
  43. gulp.watch(["index.js", "./test/**"], function () {
  44. gulp.run("jshint");
  45. cp.fork("node_modules/.bin/mocha");
  46. });
  47. });