gulpfile.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. var path = require("path");
  2. var gulp = require("gulp");
  3. var gutil = require("gulp-util");
  4. var browserify = require("gulp-browserify");
  5. var uglify = require("gulp-uglify");
  6. var rename = require("gulp-rename");
  7. var header = require("gulp-header");
  8. var mocha = require("gulp-mocha");
  9. var istanbul = require("gulp-istanbul");
  10. var package = require("./package.json");
  11. var banner =
  12. '/*!\n' +
  13. ' * ' + package.name + ' v' + package.version + '\n' +
  14. ' * Homepage ' + package.homepage + '\n' +
  15. ' * License ' + package.license + '\n' +
  16. ' */\n'
  17. gulp.task('build',['test'],function(){
  18. return gulp.src('./browser-source/*.js')
  19. .pipe(browserify())
  20. .pipe(header(banner))
  21. .pipe(gulp.dest('./dist'))
  22. .pipe(uglify())
  23. .pipe(header(banner))
  24. .pipe(rename({
  25. suffix:".min"
  26. }))
  27. .pipe(gulp.dest('./dist'));
  28. })
  29. gulp.task('pre-test', function () {
  30. return gulp.src(['src/**/*.js'])
  31. // Covering files
  32. .pipe(istanbul())
  33. // Force `require` to return covered files
  34. .pipe(istanbul.hookRequire());
  35. });
  36. //gulp.task('test',['pre-test'],function(){
  37. gulp.task('test',function(){
  38. return gulp.src('test/mocha_*.js', {read: false})
  39. .pipe(mocha({reporter: 'dot'}))
  40. // .pipe(istanbul.writeReports())
  41. // .pipe(istanbul.enforceThresholds({ thresholds: { global: 90 } }));
  42. });
  43. gulp.task('default', ['build']);