-
Notifications
You must be signed in to change notification settings - Fork 1
/
Gulpfile.js
39 lines (33 loc) · 1.01 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
'use strict';
/* global process:true */
var gulp = require('gulp');
var jshint = require('gulp-jshint');
var map = require('map-stream');
var wrap = require('gulp-wrap');
var color = require('colorful');
var myReporter = map(function (file, cb) {
if (!file.jshint.success) {
console.log(color.green('JSHINT fail:'));
file.jshint.results.forEach(function (err) {
if (err) {
err = err.error;
console.log(' '+ color.gray(file.path) + ': line ' + err.line + ', col ' + err.character + ', code ' + err.code + ', ' + color.red(err.reason));
}
});
process.exit(2);
}
cb(null, file);
});
gulp.task('jshint', function() {
return gulp.src(['index.js', './src/*.js'])
.pipe(jshint())
.pipe(myReporter);
});
gulp.task('wrap', function() {
var comments = '/* ' + new Date() + ' */\r\n';
return gulp.src('./dist/**/*.js')
.pipe(wrap( comments + '<%= contents %>'))
.pipe(gulp.dest('./dist'));
});
gulp.task('prebuild', ['jshint']);
gulp.task('postbuild', ['wrap']);