forked from esamattis/underscore.string
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
50 lines (44 loc) · 1.44 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
var gulp = require('gulp-param')(require('gulp'), process.argv),
qunit = require("gulp-qunit"),
uglify = require('gulp-uglify'),
clean = require('gulp-clean'),
bump = require('gulp-bump'),
replace = require('gulp-replace'),
rename = require('gulp-rename'),
SRC = 'lib/underscore.string.js',
DEST = 'dist',
MIN_FILE = 'underscore.string.min.js',
TEST_SUITES = ['test/test.html', 'test/test_underscore/index.html'],
VERSION_FILES = ['./package.json', './component.json'];
gulp.task('test', function() {
return gulp.src(TEST_SUITES)
.pipe(qunit());
});
gulp.task('clean', function() {
return gulp.src(DEST)
.pipe(clean());
});
gulp.task('bump-in-js', function(semver) {
gulp.src(SRC)
.pipe(replace(/(version:?\s\')([\d\.]*)\'/gi, '$1' + semver + "'"))
.pipe(gulp.dest('./lib'));
});
// usage: gulp bump -s <% Version %>
// usage: gulp bump --semver <% Version %>
gulp.task('bump', ['bump-in-js'], function(semver) {
if (typeof semver !== 'string' || semver.length <= 0) {
console.error('pass a new version `gulp bump --semver 2.4.1`');
process.exit(1);
}
return gulp.src(VERSION_FILES)
.pipe(bump({
version: semver
}))
.pipe(gulp.dest('./'));
});
gulp.task('build', ['test', 'clean'], function() {
return gulp.src(SRC)
.pipe(uglify())
.pipe(rename(MIN_FILE))
.pipe(gulp.dest(DEST));
});