-
Notifications
You must be signed in to change notification settings - Fork 248
/
gulpfile.js
93 lines (82 loc) · 2.49 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
87
88
89
90
91
92
93
var config = {
test: './test',
src: './src/',
dist: './dist/',
file: 'angular-chosen'
};
var banner = ['/**',
' * <%= pkg.name %> - <%= pkg.description %>',
' * @version v<%= pkg.version %>',
' * @link <%= pkg.homepage %>',
' * @license <%= pkg.license %>',
' */',
''].join('\n');
var args = require('yargs').argv,
gulp = require('gulp'),
karma = require('karma'),
del = require('del'),
$ = require('gulp-load-plugins')({ lazy: true }),
pkg = require('./package.json');
// List Tasks by default
gulp.task('default', $.taskListing.withFilters(null, ['build-hint']));
gulp.task('build-hint', function() {
return gulp.src(config.src + '/*.coffee')
.pipe($.if(args.debug, $.debug()))
.pipe($.plumber())
.pipe($.coffeelint('./src/coffeelint.json'))
.pipe($.coffeelint.reporter());
});
/**
* Compile CoffeeScript into ./dist/angular-chose.js
*/
gulp.task('build-coffee-script', ['build-hint'], function() {
return gulp.src(config.src + '/*.coffee')
.pipe($.if(args.debug, $.debug()))
.pipe($.plumber())
.pipe($.coffee().on('error', $.util.log))
.pipe($.rename(config.file + '.js'))
.pipe($.header(banner, { pkg : pkg }))
.pipe(gulp.dest(config.dist));
});
/**
* Minify ./dist/angular-chose.js into ./dist/angular-chose.min.js
*/
gulp.task('build-minify', ['build-coffee-script'], function() {
return gulp.src(config.dist + '/angular-chosen.js')
.pipe($.if(args.debug, $.debug()))
.pipe($.plumber())
.pipe($.uglify({mangle: true}))
.pipe($.rename(config.file + '.min.js'))
.pipe($.header(banner, {pkg : pkg}))
.pipe(gulp.dest(config.dist));
});
/**
* Run Clean Javascripts, than minify(coffee-script)
*/
gulp.task('build', ['build-clean-javascripts'], function() {
gulp.start('build-minify');
});
/**
* Clean Javascripts from .dist/
*/
gulp.task('build-clean-javascripts', function() {
return del(config.dist);
});
/**
* Watch files and compile Coffee Script in real-time
*/
gulp.task('watcher', ['tests'], function() {
gulp.watch([config.src + '*.coffee', config.dist + '*.js'], ['tests']);
});
gulp.task('test', ['build'], function (done) {
new karma.Server({
configFile: __dirname + '/test/support/karma.conf.js',
singleRun: true
}, done).start();
});
gulp.task('tests', ['build'], function (done) {
new karma.Server({
configFile: __dirname + '/test/support/karma.conf.js',
singleRun: false
}, done).start();
});