forked from SortableJS/Sortable
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
45 lines (41 loc) · 1.18 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
/* jshint ignore:start */
const gulp = require('gulp'),
uglify = require('gulp-uglify'),
rename = require('gulp-rename'),
each = require('gulp-each'),
path = require('path'),
pump = require('pump')
;
const package = require('./package.json'),
name = package.exportName,
versionExp = /(?<=\"version\":\s{0,}\")(.{0,})(?=\")/i;
gulp.task('version', function() {
let version = package.version;
return pump([
gulp.src('./*.json'),
each(function(content, file, callback){
let prevVersion = content.match(versionExp);
prevVersion && (prevVersion = prevVersion[0]);
content = content.replace(versionExp, version);
prevVersion && prevVersion !== version && console.info(`Updated version in ${ path.basename(file.history[0]) }:\t${ prevVersion } -> ${ version }`);
callback(null, content);
}),
gulp.dest('./')
]);
});
gulp.task('minify', function() {
return pump([
gulp.src(`./${ name }.js`),
uglify({
output: {
preamble: `/*! ${ name } ${ package.version } - ${ package.license } | ${ package.repository.url } */\n`
}
}),
rename({
suffix: '.min'
}),
gulp.dest(`./`)
]);
});
gulp.task('build', gulp.series('version', 'minify'));
/* jshint ignore:end */