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.

68 lines
1.8 KiB

4 years ago
  1. var coveralls = require('gulp-coveralls');
  2. var del = require('del');
  3. var gulp = require('gulp');
  4. var eslint = require('gulp-eslint');
  5. var karma = require('karma');
  6. var rename = require('gulp-rename');
  7. var runSequence = require('run-sequence');
  8. var sourcemaps = require('gulp-sourcemaps');
  9. var uglify = require('gulp-uglify');
  10. var sources = 'stackframe.js';
  11. var minified = sources.replace('.js', '.min.js');
  12. gulp.task('lint', function() {
  13. return gulp.src(sources)
  14. .pipe(eslint())
  15. .pipe(eslint.format())
  16. .pipe(eslint.failAfterError());
  17. });
  18. gulp.task('test', function(done) {
  19. new karma.Server({
  20. configFile: __dirname + '/karma.conf.js',
  21. singleRun: true
  22. }, done).start();
  23. });
  24. gulp.task('test-pr', ['copy', 'dist'], function(done) {
  25. new karma.Server({
  26. configFile: __dirname + '/karma.conf.js',
  27. browsers: ['Firefox', 'Chrome_Travis'],
  28. singleRun: true
  29. }, done).start();
  30. });
  31. gulp.task('test-ci', ['copy', 'dist'], function(done) {
  32. new karma.Server({
  33. configFile: __dirname + '/karma.conf.ci.js',
  34. singleRun: true
  35. }, done).start();
  36. });
  37. gulp.task('copy', function() {
  38. gulp.src(sources)
  39. .pipe(gulp.dest('dist'));
  40. });
  41. gulp.task('dist', ['copy'], function() {
  42. return gulp.src(sources)
  43. .pipe(sourcemaps.init())
  44. .pipe(uglify())
  45. .pipe(rename(minified))
  46. .pipe(sourcemaps.write('./'))
  47. .pipe(gulp.dest('dist'));
  48. });
  49. gulp.task('clean', del.bind(null, ['build', 'coverage', 'dist']));
  50. gulp.task('pr', ['lint', 'test-pr']);
  51. gulp.task('ci', ['lint', 'test-ci'], function() {
  52. gulp.src('./coverage/**/lcov.info')
  53. .pipe(coveralls());
  54. });
  55. gulp.task('default', ['clean'], function(cb) {
  56. runSequence('lint', ['copy', 'dist'], 'test', cb);
  57. });