From 22bde573d6f2a63b23e300129d0f8603d547875f Mon Sep 17 00:00:00 2001 From: David Molineus Date: Thu, 23 Aug 2018 15:33:13 +0200 Subject: [PATCH] Switch to gulp v4. --- .gitignore | 4 ++++ gulpfile.js | 47 +++++++++++++++++++++++++++-------------------- package.json | 5 ++--- 3 files changed, 33 insertions(+), 23 deletions(-) diff --git a/.gitignore b/.gitignore index a4e22b1..b0b7dd9 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,10 @@ nbproject/ vendor/ composer.lock +# Node +/node_modules +package-lock.json + # build build/ build.properties diff --git a/gulpfile.js b/gulpfile.js index b5ad94d..e2f35ac 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,4 +1,5 @@ -var gulp = require('gulp'); +const { series, parallel, src, dest } = require('gulp'); + var del = require('del'); var rename = require('gulp-rename'); var uglify = require('gulp-uglify'); @@ -29,16 +30,12 @@ var paths = [ dest: 'assets/leaflet-fullscreen', css: 'Control.FullScreen.css', js: 'Control.FullScreen.js' - }, - { - dest: 'assets/leaflet-layer-overpass', - css: 'OverPassLayer.css' } ]; -gulp.task('clear-styles', function() { +function clearStyles (cb) { var i, clear = []; - + for (i = 0; i < paths.length; i++) { if (paths[i].css) { clear.push(paths[i].dest + '/*.min.css'); @@ -46,9 +43,11 @@ gulp.task('clear-styles', function() { } del(clear); -}); -gulp.task('clear-scripts', function() { + cb(); +} + +function clearScripts (cb) { var i, clear = []; for (i = 0; i < paths.length; i++) { @@ -58,45 +57,53 @@ gulp.task('clear-scripts', function() { } del(clear); -}); -gulp.task('scripts', ['clear-scripts'], function() { + cb(); +} + +const scripts = series(clearScripts, function (cb) { var i, stream, streams = []; for (i = 0; i < paths.length; i++) { if (paths[i].js) { - stream = gulp.src(paths[i].dest + '/' + paths[i].js) + stream = src(paths[i].dest + '/' + paths[i].js) .pipe(rename(function (path) { path.basename += '.min'; })) .pipe(uglify()) - .pipe(gulp.dest(paths[i].dest)); + .pipe(dest(paths[i].dest)); streams.push(stream); } } - return merge.call(null, streams); + merge.call(null, streams); + + cb(); }); -gulp.task('styles', ['clear-styles'], function() { +const styles = series(clearStyles, function (cb) { var i, stream, streams = []; for (i = 0; i < paths.length; i++) { if (paths[i].css) { - stream = gulp.src(paths[i].dest + '/' + paths[i].css) + stream = src(paths[i].dest + '/' + paths[i].css) .pipe(rename(function (path) { path.basename += '.min'; })) .pipe(minifyCss()) .pipe(replace(/url\(([^"][^\)]+)\)/g, 'url(\'$1\')')) - .pipe(gulp.dest(paths[i].dest)); + .pipe(dest(paths[i].dest)); streams.push(stream); } } - return merge.call(null, streams); -}); + merge.call(null, streams); -gulp.task('default', ['scripts', 'styles']); + cb(); +}) + +exports.scripts = scripts; +exports.styles = styles; +exports.default = parallel(scripts, styles); diff --git a/package.json b/package.json index 253dd3b..da4e384 100644 --- a/package.json +++ b/package.json @@ -5,12 +5,11 @@ "main": "gulpfile.js", "dependencies": { "del": "^2.2.2", - "gulp": "^3.9.1", + "gulp": "^4.0.0", "gulp-minify-css": "^1.2.4", - "gulp-rename": "^1.2.2", + "gulp-rename": "^1.4.0", "gulp-replace": "^0.5.4", "gulp-uglify": "^2.0.0", - "gulp-util": "^3.0.7", "merge-stream": "^1.0.0" }, "devDependencies": {},