From 6a58f133c17ce21004765c353e399f9a37c1ab9b Mon Sep 17 00:00:00 2001 From: Assaf Arkin Date: Tue, 27 Nov 2018 09:45:24 -0800 Subject: [PATCH] Use Gulp 4.x --- Gulpfile.js | 74 +++++++++++++++++++++++++---------------------- package-lock.json | 2 +- 2 files changed, 41 insertions(+), 35 deletions(-) diff --git a/Gulpfile.js b/Gulpfile.js index 6f68e7468..3097b64af 100644 --- a/Gulpfile.js +++ b/Gulpfile.js @@ -10,21 +10,20 @@ const sourcemaps = require('gulp-sourcemaps'); const babel = require('gulp-babel'); -// gulp -> gulp watch -gulp.task('default', ['watch']); - - -// gulp lint -> errors if code dirty -gulp.task('lint', function () { +function lint() { return gulp.src([ 'src/**/*.js', 'test/*.js' ]) .pipe(eslint()) .pipe(eslint.formatEach()) .pipe(eslint.failOnError()); -}); +} -// gulp build -> compile coffee script -gulp.task('build', ['clean'], function() { +function clean() { + return del('lib/**'); +} + + +function build() { return gulp.src('src/**/*.js') .pipe(sourcemaps.init()) .pipe(babel()) @@ -34,23 +33,31 @@ gulp.task('build', ['clean'], function() { message: 'Zombie: built!', onLast: true })); -}); +} -// gulp clean -> clean generated files -gulp.task('clean', function() { - return del('lib/**'); -}); +function watch() { + return gulp.watch('src/*.js', gulp.series(clean, build)); +} -// gulp watch -> watch for changes and compile -gulp.task('watch', ['build'], function() { - return gulp.watch('src/*.js', ['clean', 'build']); -}); +// Generate a change log summary for this release +// git tag uses the generated .changes file +function changes() { + const version = require('./package.json').version; + const changelog = File.readFileSync('CHANGELOG.md', 'utf-8'); + const match = changelog.match(/^## Version (.*) .*\n([\S\s]+?)\n##/m); + assert(match, 'CHANGELOG.md missing entry: ## Version ' + version); + assert.equal(match[1], version, 'CHANGELOG.md missing entry for version ' + version); -// gulp tag -> Tag this release -gulp.task('tag', ['changes'], function() { + const changes = match[2].trim(); + assert(changes, 'CHANGELOG.md empty entry for version ' + version); + File.writeFileSync('.changes', changes); +} + + +function tag() { const version = require('./package.json').version; const tag = 'v' + version; @@ -61,20 +68,19 @@ gulp.task('tag', ['changes'], function() { .pipe( exec('git tag ' + tag + ' --file .changes') ) .pipe( exec('git push origin ' + tag) ) .pipe( exec('git push origin master') ); -}); - -// Generate a change log summary for this release -// git tag uses the generated .changes file -gulp.task('changes', function() { - const version = require('./package.json').version; - const changelog = File.readFileSync('CHANGELOG.md', 'utf-8'); - const match = changelog.match(/^## Version (.*) .*\n([\S\s]+?)\n##/m); +} - assert(match, 'CHANGELOG.md missing entry: ## Version ' + version); - assert.equal(match[1], version, 'CHANGELOG.md missing entry for version ' + version); - const changes = match[2].trim(); - assert(changes, 'CHANGELOG.md empty entry for version ' + version); - File.writeFileSync('.changes', changes); -}); +// gulp build -> compile coffee script +exports.build = gulp.series(clean, build, lint); +// gulp clean -> clean generated files +exports.clean = clean; +// gulp lint -> errors if code dirty +exports.lint = lint; +// gulp watch -> watch for changes and compile +exports.watch = gulp.series(build, watch); +// gulp tag -> Tag this release +exports.tag = gulp.series(changes, tag); +// gulp -> gulp watch +exports.default = exports.watch; diff --git a/package-lock.json b/package-lock.json index 88200f130..62c410156 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "zombie", - "version": "6.1.3", + "version": "6.1.4", "lockfileVersion": 1, "requires": true, "dependencies": {