gulpfile.js 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. var path = require("path");
  2. var gulp = require("gulp");
  3. var util = require("gulp-util");
  4. var mocha = require("gulp-mocha");
  5. var browserify = require("gulp-browserify");
  6. var uglify = require("gulp-uglify");
  7. var rename = require("gulp-rename");
  8. var header = require("gulp-header");
  9. var package = require("./package.json");
  10. var banner =
  11. '/*!\n' +
  12. ' * ' + package.name + ' v' + package.version + '\n' +
  13. ' * Homepage ' + package.homepage + '\n' +
  14. ' * License ' + package.license + '\n' +
  15. ' */\n'
  16. gulp.task('build',['test'],function(){
  17. return gulp.src('./browser-source.js')
  18. .pipe(browserify())
  19. .pipe(header(banner))
  20. .pipe(rename({
  21. basename:package.name
  22. }))
  23. .pipe(gulp.dest('./dist'))
  24. .pipe(uglify())
  25. .pipe(header(banner))
  26. .pipe(rename({
  27. basename:package.name+".min"
  28. }))
  29. .pipe(gulp.dest('./dist'));
  30. })
  31. gulp.task('test',function(){
  32. return gulp.src('test/*.js', {read: false})
  33. .pipe(mocha({reporter: 'nyan'}))
  34. });
  35. gulp.task('default', ['build']);