forked from jbmusso/grex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
67 lines (53 loc) · 1.65 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
66
var gulp = require('gulp');
var browserify = require('gulp-browserify');
var jshint = require('gulp-jshint');
var mocha = require('gulp-mocha');
var uglify = require('gulp-uglify');
var size = require('gulp-size');
var rename = require('gulp-rename');
var bump = require('gulp-bump');
gulp.task('scripts', function() {
gulp.src('index.js')
.pipe(browserify())
.pipe(jshint())
.pipe(rename('grex.js'))
.pipe(gulp.dest('./build'))
.pipe(size({ showFiles: true }))
// Minified version
.pipe(uglify())
.pipe(rename('grex.min.js'))
.pipe(gulp.dest('./build'))
.pipe(size({ showFiles: true }));
});
gulp.task('test', function() {
require('should');
gulp.src('test/**/*')
.pipe(mocha({
reporter: 'spec',
}))
.on('error', function(error) {
console.error('\nError:', error.plugin);
console.error(error.message);
});
});
gulp.task('watch', function() {
function onChange(event) {
console.log('File', event.type +':', event.path);
}
gulp.watch('src/**/*', ['test']).on('change', onChange);
gulp.watch('test/**/*', ['test']).on('change', onChange);
});
// Bump tasks
gulp.task('bump-patch', function() {
gulp.src('./package.json').pipe(bump({ type: 'patch' })).pipe(gulp.dest('./'));
});
gulp.task('bump-minor', function() {
gulp.src('./package.json').pipe(bump({ type: 'minor' })).pipe(gulp.dest('./'));
});
gulp.task('bump-major', function() {
gulp.src('./package.json').pipe(bump({ type: 'major' })).pipe(gulp.dest('./'));
});
// Main tasks
gulp.task('default', ['dev']);
gulp.task('dev', ['test', 'watch']);
gulp.task('build', ['test', 'scripts']);