1 | const gulp = require('gulp')
|
2 | const ava = require('gulp-ava')
|
3 | const eslint = require('gulp-eslint')
|
4 | const rename = require('gulp-rename')
|
5 | const sourcemaps = require('gulp-sourcemaps')
|
6 | const uglify = require('gulp-uglify-es').default
|
7 | const pump = require('pump')
|
8 |
|
9 | gulp.task('lint', () => gulp.src(['**/*.js', '!docs/**', '!node_modules/**', '!dist/**', '!test/helpers/**/*.js'])
|
10 | .pipe(eslint({
|
11 | parser: 'babel-eslint',
|
12 | rules: {
|
13 |
|
14 | 'curly': 'error',
|
15 | 'eqeqeq': 'error',
|
16 | 'new-parens': 'error',
|
17 | 'no-cond-assign': 'error',
|
18 | 'no-console': 'error',
|
19 | 'no-debugger': 'error',
|
20 | 'no-empty': 'error',
|
21 | 'no-fallthrough': 'error',
|
22 | 'no-trailing-spaces': 'error',
|
23 | 'no-mixed-spaces-and-tabs': 'error',
|
24 | }
|
25 | }))
|
26 | .pipe(eslint.format())
|
27 | .pipe(eslint.failAfterError()))
|
28 |
|
29 | gulp.task('test', () => gulp.src('test/**/*.js')
|
30 | .pipe(ava({ verbose: true })))
|
31 |
|
32 | gulp.task('watch', () => {
|
33 | gulp.watch(['chance.js', 'gulpfile.js', 'test/**/*.js'], ['lint', 'test'])
|
34 | })
|
35 |
|
36 | gulp.task('watch-lint', () => {
|
37 | gulp.watch(['chance.js', 'gulpfile.js', 'test/**/*.js'], ['lint'])
|
38 | })
|
39 |
|
40 | gulp.task('build', (cb) => {
|
41 | pump([ gulp.src('chance.js'), sourcemaps.init(),
|
42 | rename('chance.min.js'), uglify(), sourcemaps.write('.'),
|
43 | gulp.dest('dist'),
|
44 | ], cb)
|
45 | })
|
46 |
|
47 | gulp.task('travis', gulp.series('lint', 'test'))
|
48 |
|
49 | gulp.task('default', gulp.series('watch', 'lint', 'test'))
|