forked from LuvDaSun/angular-hal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gulpfile.js
86 lines (77 loc) · 1.96 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
var gulp = require('gulp')
, uglify = require('gulp-uglify')
, concat = require('gulp-concat')
, watch = require('gulp-watch')
, jshint = require('gulp-jshint')
, gulpUtil = require('gulp-util')
, angularFilesort = require('gulp-angular-filesort')
, karma = require('karma')
, eslint = require('gulp-eslint')
, sourcemaps = require('gulp-sourcemaps');
gulp.task('default', [
'compress',
]);
gulp.task('watch', function() {
gulp.start('compress');
watch(__dirname + '/src/**/*.js', function() {
gulp.start('compress');
gulp.start('jshint');
});
watch(__dirname + '/test/**/*.js', function() {
gulp.start('compress');
gulp.start('jshint');
});
});
gulp.task('test', [
'karma',
'jshint',
'eslint',
]);
gulp.task('compress', [
'compress:minified',
'compress:unminified',
]);
gulp.task('compress:unminified', function() {
return gulp.src(__dirname + '/src/**/*.js')
.pipe(sourcemaps.init())
.pipe(angularFilesort())
.pipe(concat('angular-hal.js'))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(__dirname));
});
gulp.task('compress:minified', function() {
return gulp.src(__dirname + '/src/**/*.js')
.pipe(sourcemaps.init())
.pipe(angularFilesort())
.pipe(uglify())
.on('error', gulpUtil.log)
.pipe(concat('angular-hal.min.js'))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(__dirname));
});
gulp.task('jshint', function() {
return gulp.src([__dirname + '/src/**/*.js', __dirname + '/test/**/*.js'])
.pipe(jshint(__dirname + '/.jshintrc'))
.pipe(jshint.reporter('jshint-stylish'));
});
gulp.task('eslint', function() {
return gulp.src([__dirname + '/src/**/*.js', __dirname + '/test/**/*.js'])
.pipe(eslint())
.pipe(eslint.format());
});
gulp.task(
'karma',
[
'compress',
],
function (done) {
var server = new karma.Server(
{
configFile: __dirname + '/karma.conf.js',
singleRun: true
},
done
);
server.start();
}
);