-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathgulpfile.js
56 lines (46 loc) · 1.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
var gulp = require( 'gulp' ),
del = require( 'del' ),
Karma = require( 'karma' ).Server,
$ = require( 'gulp-load-plugins' )( { lazy: true } ),
config = require( './gulp.config.js' )(),
pkg = require('./package.json');
// List Tasks by default
gulp.task( 'default', $.taskListing );
gulp.task( 'hint', function() {
return gulp.src( config.jsSrc )
.pipe( $.plumber() )
.pipe( $.jshint() )
.pipe( $.jshint.reporter( 'jshint-stylish', { verbose: true } ) )
.pipe( $.jscs() )
} );
var banner = ['/**',
' * <%= pkg.name %> - <%= pkg.description %>',
' * @version v<%= pkg.version %>',
' * @link <%= pkg.homepage %>',
' * @license <%= pkg.license %>',
' */',
''].join('\n');
gulp.task( 'minify', [ 'hint', 'clean-javascripts' ], function() {
return gulp.src( config.jsSrc )
.pipe( $.plumber() )
.pipe( $.uglify( { mangle: true } ) )
.pipe( $.rename( 'jquery.stringtoslug.min.js' ) )
.pipe( $.header(banner, { pkg : pkg } ))
.pipe( gulp.dest( config.jsDest ) )
} );
gulp.task( 'tests', [ 'minify' ], function() {
new Karma( {
configFile: __dirname + '/karma.conf.js',
singleRun: true
} ).start();
} );
gulp.task( 'build', [ 'tests' ] );
gulp.task( 'clean-javascripts', function() {
del( config.jsDest );
} );
gulp.task( 'watcher', [ 'minify' ], function() {
gulp.watch( [ config.jsSrc ], [ 'minify' ] );
} );
function clean( path, done ) {
del( path, done );
}