From a1fd48752ef8e1d7e66c649e8e707dd2ff7140b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Thu, 28 Sep 2017 15:04:37 +0200 Subject: [PATCH] Gulp: added 'cleanup' task that erases all gulp-generated files. It uses Git to erase those files, so anything that's tracked in Git (such as the JS/CSS vendor directories) are kept as-is. --- gulpfile.js | 14 ++++++++++++++ package.json | 1 + 2 files changed, 15 insertions(+) diff --git a/gulpfile.js b/gulpfile.js index 282e85a3..b90b9b0f 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -3,6 +3,7 @@ var autoprefixer = require('gulp-autoprefixer'); var cache = require('gulp-cached'); var chmod = require('gulp-chmod'); var concat = require('gulp-concat'); +var git = require('gulp-git'); var gulpif = require('gulp-if'); var gulp = require('gulp'); var livereload = require('gulp-livereload'); @@ -112,6 +113,19 @@ gulp.task('watch',function() { gulp.watch('src/scripts/markdown/**/*.js',['scripts_concat_markdown']); }); +// Erases all generated files in output directories. +gulp.task('cleanup', function() { + var paths = []; + for (attr in destination) { + paths.push(destination[attr]); + } + + git.clean({ args: '-f -X ' + paths.join(' ') }, function (err) { + if(err) throw err; + }); + +}); + // Run 'gulp' to build everything at once gulp.task('default', ['styles', 'templates', 'scripts', 'scripts_concat_tutti', 'scripts_concat_markdown']); diff --git a/package.json b/package.json index 83fe7e30..feaea58a 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "gulp-chmod": "~1.3.0", "gulp-concat": "~2.6.0", "gulp-if": "^2.0.1", + "gulp-git": "~2.4.2", "gulp-livereload": "~3.8.1", "gulp-plumber": "~1.1.0", "gulp-pug": "~3.2.0",