-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathgulpfile.js
95 lines (85 loc) · 2.55 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
94
95
var gulp = require( "gulp" );
var gutil = require( "gulp-util" );
var sourcemaps = require( "gulp-sourcemaps" );
var rename = require( "gulp-rename" );
var header = require( "gulp-header" );
var pkg = require( "./package.json" );
var hintNot = require( "gulp-hint-not" );
var uglify = require( "gulp-uglify" );
var jshint = require( "gulp-jshint" );
var jscs = require( "gulp-jscs" );
var gulpChanged = require( "gulp-changed" );
var banner = [ "/**",
" * <%= pkg.name %> - <%= pkg.description %>",
" * Author: <%= pkg.author %>",
" * Version: v<%= pkg.version %>",
" * Url: <%= pkg.homepage %>",
" * License(s): <% pkg.licenses.forEach(function( license, idx ){ %><%= license.type %> Copyright (c) <%= ( new Date() ).getFullYear() %> LeanKit<% if(idx !== pkg.licenses.length-1) { %>, <% } %><% }); %>",
" */",
"" ].join( "\n" );
function buildLib() {
return gulp.src( "src/halon.js" )
.pipe( hintNot() )
.pipe( sourcemaps.init() )
.pipe( header( banner, {
pkg: pkg
} ) )
.pipe( gulp.dest( "lib/" ) );
}
gulp.task( "build:quick", function() {
return buildLib();
} );
gulp.task( "build:minified", [ "format" ], function() {
return buildLib()
.pipe( header( banner, {
pkg: pkg
} ) )
.pipe( sourcemaps.write() )
.pipe( uglify( {
compress: {
negate_iife: false // jshint ignore:line
}
} ) )
.pipe( header( banner, {
pkg: pkg
} ) )
.pipe( rename( "halon.min.js" ) )
.pipe( gulp.dest( "lib/" ) );
} );
gulp.task( "default", [ "build:minified" ] );
var mocha = require( "gulp-spawn-mocha" );
gulp.task( "mocha", function() {
return gulp.src( [ "spec/**/*.spec.js" ], { read: false } )
.pipe( mocha( {
require: [ "spec/helpers/node-setup.js" ],
reporter: "spec",
colors: true,
inlineDiffs: true,
debug: false
} ) )
.on( "error", console.warn.bind( console ) );
} );
gulp.task( "jshint", function() {
return gulp.src( [ "src/**/*.js", "spec/**/*.spec.js" ] )
.pipe( jshint() )
.pipe( jshint.reporter( "jshint-stylish" ) )
.pipe( jshint.reporter( "fail" ) );
} );
gulp.task( "format", [ "jshint" ], function() {
return gulp.src( [ "**/*.js", "!node_modules/**" ] )
.pipe( jscs( {
configPath: ".jscsrc",
fix: true
} ) )
.on( "error", function( error ) {
gutil.log( gutil.colors.red( error.message ) );
this.end();
} )
.pipe( gulpChanged( ".", { hasChanged: gulpChanged.compareSha1Digest } ) )
.pipe( gulp.dest( "." ) );
} );
gulp.task( "watch", function() {
gulp.watch( "src/**/*", [ "default" ] );
gulp.watch( "{lib,spec}/**/*", [ "mocha" ] );
} );
gulp.task( "continuous", [ "mocha", "watch" ] );