-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.js
46 lines (42 loc) · 1.1 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
const gulp = require('gulp');
const eslint = require('gulp-eslint');
const mocha = require('gulp-mocha');
const path = require('path');
const { execSync } = require('child_process');
const updateCheck = require('update-notifier');
const packageJSON = require('./package.json');
gulp.task('unit_tests', () => {
return gulp.src(path.join(__dirname, 'tests', '*.test.js'), { read: false })
.pipe(mocha({
reporter: 'spec',
timeout: 20000
}));
});
gulp.task('lint', (done) => {
return gulp.src(['src/**/*.js'])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError())
.on('finish', () => done());
});
gulp.task('deploy', () => {
updateCheck({
pkg: packageJSON,
updateCheckInterval: 0,
callback: (err, update) => {
if (err) {
return err;
}
if (update.current !== update.latest) {
try {
execSync('npm publish');
} catch (error) {
return err;
}
} else {
return console.log('Nothing to deploy.');
}
}
});
});
gulp.task('default', gulp.series(['lint', 'unit_tests']));