forked from mtraynham/lodash-joins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
139 lines (125 loc) · 3.84 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
var gulp = require('gulp'),
benchmark = require('gulp-bench'),
browserify = require('browserify'),
browserifyShim = require('browserify-shim'),
bump = require('gulp-bump'),
coveralls = require('gulp-coveralls'),
istanbul = require('gulp-istanbul'),
jscs = require('gulp-jscs'),
jshint = require('gulp-jshint'),
jshintStylish = require('jshint-stylish'),
mocha = require('gulp-mocha'),
rename = require('gulp-rename'),
source = require('vinyl-source-stream'),
streamify = require('gulp-streamify'),
tslint = require('gulp-tslint'),
uglify = require('gulp-uglify'),
watchify = require('watchify');
gulp.task('lint', function () {
return gulp
.src(['gulpfile.js', 'index.js', 'lib/*.js', 'lib/**/*.js', 'test/*.js'])
.pipe(jscs())
.pipe(jshint())
.pipe(jshint.reporter(jshintStylish));
});
gulp.task('build', function () {
var bundler = browserify({
basedir: __dirname,
entries: ['./index.js'],
extensions: ['.js'],
debug: global.isDevelopment ? false : true,
cache: {},
packageCache: {},
fullPaths: false
}).transform(browserifyShim);
var bundle = function () {
return bundler
.bundle()
.pipe(source('dist/lodash-joins.js'))
.pipe(gulp.dest('./'))
.pipe(streamify(uglify()))
.pipe(rename('dist/lodash-joins.min.js'))
.pipe(gulp.dest('./'));
};
if (global.isWatching) {
bundler = watchify(bundler);
bundler.on('update', bundle);
}
return bundle();
});
gulp.task('test', function () {
gulp.src(['lib/**/*.js', 'main.js'])
.pipe(istanbul()) // Covering files
.pipe(istanbul.hookRequire())
.on('finish', function () {
gulp.src(['test/*.js'])
.pipe(mocha())
.pipe(istanbul.writeReports()) // Creating the reports after tests runned
.on('end', function () {
gulp.src('coverage/lcov.info')
.pipe(coveralls());
});
});
});
gulp.task('benchmark', function () {
return gulp.src('bench/*.js', {read: false})
.pipe(benchmark());
});
gulp.task('tslint', function () {
return gulp
.src(['lib/*.ts'])
.pipe(tslint({
configuration: '.tslintrc'
}))
.pipe(tslint.report());
});
gulp.task('tsbuild', function () {
var bundler = browserify({
basedir: __dirname,
entries: ['./lib/join.ts'],
extensions: ['.ts'],
debug: global.isDevelopment ? false : true,
cache: {},
packageCache: {},
fullPaths: false
}).transform(browserifyShim)
.plugin('tsify', {noImplicitAny: true});
var bundle = function () {
return bundler
.bundle()
.pipe(source('dist/lodash-joins.js'))
.pipe(gulp.dest('./'))
.pipe(streamify(uglify()))
.pipe(rename('dist/lodash-joins.min.js'))
.pipe(gulp.dest('./'));
};
if (global.isWatching) {
bundler = watchify(bundler);
bundler.on('update', bundle);
}
return bundle();
});
gulp.task('setWatch', function () {
global.isWatching = true;
});
gulp.task('setDevelopment', function () {
global.isDevelopment = true;
});
var bumpFn = function (type) {
gulp.src(['./bower.json', './package.json'])
.pipe(bump({type: type}))
.pipe(gulp.dest('./'));
};
// Default Task
gulp.task('default', ['setDevelopment', 'lint', 'build']);
gulp.task('watch', ['setDevelopment', 'setWatch', 'lint', 'build']);
gulp.task('release', ['lint', 'build']);
gulp.task('bump:major', function () {
bumpFn('major');
});
gulp.task('bump:minor', function () {
bumpFn('minor');
});
gulp.task('bump:patch', function () {
bumpFn('patch');
});