forked from stevenorell/jquery-backstretch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
64 lines (58 loc) · 1.7 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
var gulp = require('gulp')
, _ = require('lodash')
, jshint = require('gulp-jshint')
, uglify = require('gulp-uglify')
, rename = require('gulp-rename')
, bump = require('gulp-bump')
, argv = require('yargs').argv
, header = require('gulp-header')
, strip = require('gulp-strip-banner');
var today = new Date();
var src = 'src/*.js';
var pkg = require('./package.json');
var banner = '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
today.getFullYear() + '-' + ( today.getMonth() < 10 ? '0' : '' ) + ( today.getMonth() + 1 ) + '-' + today.getDate() + '\n' +
( pkg.homepage ? '* <%= pkg.homepage %>\n' : '' ) +
'* Copyright (c) <%= today.getFullYear() %> <%= pkg.author.name %>;' +
' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */' + '\n\n';
gulp.task('lint', function(){
gulp.src(src)
.pipe(jshint({
curly: true,
eqeqeq: true,
immed: true,
latedef: true,
newcap: true,
noarg: true,
sub: true,
undef: true,
boss: true,
eqnull: true,
browser: true,
laxcomma: true,
globals: {
'jQuery': true
}
}))
.pipe(jshint.reporter('default'))
});
gulp.task('min', function(){
gulp.src(src)
.pipe(strip())
.pipe(header(banner, { pkg : pkg, today: today, _: _ } ))
.pipe(gulp.dest('.'))
.pipe(uglify({
preserveComments: 'some'
}))
.pipe(rename({
suffix: '.min'
}))
.pipe(gulp.dest('./'));
});
gulp.task('default', ['lint', 'min']);
gulp.task('bump', function(){
var type = argv.type || 'patch';
gulp.src(['package.json', 'bower.json'])
.pipe(bump({ type: type }))
.pipe(gulp.dest('./'));
});