forked from cabrel/angular-lodash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
68 lines (59 loc) · 1.86 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
67
68
(function() {
'use strict';
var gulp = require('gulp');
var dateFormat = require('dateformat');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var header = require('gulp-header');
var ngAnnotate = require('gulp-ng-annotate');
var KarmaServer = require('karma').Server;
var jshint = require('gulp-jshint');
var connect = require('gulp-connect');
var pkg = {};
var banner = ['/**',
' * <%= pkg.name %> - <%= pkg.description %>',
' * @build time <%= buildTime %>',
' * @author <%= pkg.author %>',
' * @version v<%= pkg.version %>',
' * @license <%= pkg.license %>',
' */',
''].join('\n');
var buildTime = '';
gulp.task('example', function() {
connect.server();
});
gulp.task('jshint', function() {
gulp.src([
'./gulpfile.js',
'./*.js',
'./test/**/*.js',
'./example/*.html'])
.pipe(jshint.extract())
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter('jshint-stylish'));
});
gulp.task('test', ['jshint'], function() {
new KarmaServer({
configFile: __dirname + '/karma.config.js',
singleRun: true
}).start();
});
gulp.task('minify', function() {
pkg = require('./package.json');
buildTime = dateFormat(new Date(), 'yyyy-MM-dd HH:MM');
gulp.src('angular-lodash.js')
.pipe(ngAnnotate({single_quotes: true}))
.pipe(uglify())
.pipe(header(banner, {pkg : pkg, buildTime: buildTime}))
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest('./dist'));
});
gulp.task('build', ['test', 'minify'], function() {
/*Note: pkg and buildTime are resolved in minification process.*/
gulp.src('angular-lodash.js')
.pipe(ngAnnotate({single_quotes: true}))
.pipe(header(banner, {pkg : pkg, buildTime: buildTime}))
.pipe(gulp.dest('./dist'));
});
gulp.task('default', ['jshint']);
})();