-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathgulpfile.js
54 lines (46 loc) · 1.36 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
var gulp = require('gulp'),
replace = require('gulp-replace'),
jshint = require('gulp-jshint'),
rename = require('gulp-rename'),
uglify = require('gulp-uglify'),
qunit = require('gulp-qunit'),
package = require('./package.json');
var paths = {
source: ['chibi.js'],
readme: ['README.md'],
test: ['tests/runner.html']
};
var handleError = function(err) {
process.exit(1);
}
gulp.task('update', function(callback) {
gulp.src(paths.source)
.pipe(replace(/(\/\*!)(.*)(\*\/)/g, '$1chibi '+package.version+', Copyright 2012-'+(new Date()).getUTCFullYear()+' '+package.author.name+', released under '+package.license+' license $3'))
.pipe(gulp.dest(''))
gulp.src(paths.readme)
.pipe(replace(/(\# Chibi v)([\d\.]*)/g, '$1'+package.version))
.pipe(gulp.dest(''))
.on('end', callback);
});
gulp.task('lint', function() {
gulp.src(paths.source)
.pipe(jshint())
.pipe(jshint.reporter('default'))
.pipe(jshint.reporter('fail'))
.on('error', handleError);
});
gulp.task('compress', function() {
gulp.src(paths.source)
.pipe(rename('chibi-min.js'))
.pipe(uglify({output: {comments: /^!/i}}))
.pipe(gulp.dest(''));
});
gulp.task('test', function() {
gulp.src(paths.test)
.pipe(qunit())
.on('error', handleError);
});
gulp.task('watch', function() {
gulp.watch(paths.source, ['lint', 'compress']);
});
gulp.task('default', ['lint', 'compress', 'test']);