Skip to content
This repository has been archived by the owner on Dec 16, 2023. It is now read-only.

Commit

Permalink
Use Gulp 4.x
Browse files Browse the repository at this point in the history
  • Loading branch information
assaf committed Nov 27, 2018
1 parent b60fd3d commit 6a58f13
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 35 deletions.
74 changes: 40 additions & 34 deletions Gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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;

Expand All @@ -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;

2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6a58f13

Please sign in to comment.