diff --git a/gulpfile.js b/gulpfile.js index e300ecf..bf1747b 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -5,6 +5,7 @@ const exec = require('gulp-exec'); const eslint = require('gulp-eslint'); const del = require('del'); +// Build scripts gulp.task('build', () => gulp.src('src/**/*.js') .pipe(sourcemaps.init()) @@ -13,8 +14,13 @@ gulp.task('build', () => .pipe(gulp.dest('lib')) ); +// Clean built scripts gulp.task('clean', () => del('lib/**')); +// Clean then build +gulp.task('rebuild', gulp.series('clean', 'build')); + +// Lint scripts gulp.task('lint', () => gulp.src('src/**/*.js') .pipe(eslint()) @@ -22,14 +28,19 @@ gulp.task('lint', () => .pipe(eslint.failAfterError()) ); -gulp.task('rebuild', gulp.series('clean', 'build')); -gulp.task('default', gulp.parallel('lint', 'rebuild')); - -gulp.task('publish', gulp.series('default', () => { +// Commit & tag version +gulp.task('tag-release', () => { const version = require('./package.json').version; return gulp.src('.') .pipe(exec(`git commit -am "Prepare ${version} release"`)) .pipe(exec(`git tag v${version}`)) - .pipe(exec(`git push origin : v${version}`)) - .pipe(exec('npm publish')); -})); + .pipe(exec(`git push origin : v${version}`)); +}); + +// Commit & tag and publish to NPM +gulp.task('publish', gulp.parallel('lint', gulp.series('rebuild', 'tag-release', () => + gulp.src('.') + .pipe(exec('npm publish')) +))); + +gulp.task('default', gulp.parallel('lint', 'rebuild'));