-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
45 lines (38 loc) · 1.38 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
'use strict';
var gulp = require('gulp');
var bump = require('gulp-bump');
var gutil = require('gulp-util');
var uglify = require('gulp-uglify');
var sourcemaps = require('gulp-sourcemaps');
var rename = require("gulp-rename");
var fs = require('fs');
var karmaServer = require('karma').Server;
var jshint = require('gulp-jshint').Server;
var karmaConfig = '/test/resources/karma.conf.js';
var cwd = process.cwd();
var getPackageJson = function() {
return JSON.parse(fs.readFileSync('./package.json', 'utf8'));
};
// Default task
// Internal use - updates package.json with minor version increment
gulp.task('version-bump', function() {
return gulp.src([ cwd + '/package.json' ]).pipe(bump()).pipe(gulp.dest('./'));
});
gulp.task('test', function(done) {
new karmaServer({
configFile : __dirname + karmaConfig,
singleRun : true
}, function() {
done();
}).start();
});
gulp.task('lint', function() {
return gulp.src('src/*.js').pipe(jshint('.jshintrc')).pipe(jshint.reporter('jshint-stylish')).pipe(jshint.reporter('fail'));
});
gulp.task('release', [ 'version-bump', 'test' ], function() {
gulp.src('src/*.js').pipe(sourcemaps.init({
loadMaps : true
})).pipe(uglify({
mangle : false
})).on('error', gutil.log.bind(gutil, 'JS minify Error')).pipe(rename('angular-cache-service.min.js')).pipe(sourcemaps.write('./')).pipe(gulp.dest('./dist'));
});