forked from laurisvan/request-promise-lite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
65 lines (54 loc) · 1.62 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
const babel = require('gulp-babel');
const bump = require('gulp-bump');
const eslint = require('gulp-eslint');
const gulp = require('gulp');
const minimist = require('minimist');
const mocha = require('gulp-mocha');
const sequence = require('gulp-sequence');
const sourcemaps = require('gulp-sourcemaps');
const defaults = { type: 'patch' };
const options = minimist(process.argv.slice(2), defaults);
gulp.task('eslint', () => {
return gulp.src(['src/**/*.js', 'test/**/*.js', 'gulpfile.js'])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});
gulp.task('mocha', () => {
return gulp.src('test/test.js', { read: false, timeout: 5000 })
.pipe(mocha());
});
gulp.task('bump', () => {
gulp.src('./package.json')
.pipe(bump({ type: options.type }))
.pipe(gulp.dest('./'));
});
gulp.task('watch', () => {
return gulp.watch(['src/**/*.js'], ['default']);
});
gulp.task('default', () => {
function reportError(error) {
// If you want details of the error in the console
console.warn(error.toString());
console.warn(error.message);
this.emit('end');
}
// TODO We should merge these two streams
gulp.src(['src/**/*.json'])
.pipe(gulp.dest('lib'));
return gulp.src(['src/**/*.js'])
.pipe(sourcemaps.init())
.pipe(babel({
presets: ['es2015-node4'],
plugins: ['add-module-exports'],
comments: false,
babelrc: false,
}))
.on('error', reportError)
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('lib'));
});
// Aliases
gulp.task('validate', ['eslint']);
gulp.task('test', sequence('validate', 'mocha'));
gulp.task('build', ['default']);