diff --git a/gulpfile.js b/gulpfile.js index 4f8ce93..fbb434b 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -2,6 +2,7 @@ var argv = require('minimist')(process.argv.slice(2)); var autoprefixer = require('gulp-autoprefixer'); var chmod = require('gulp-chmod'); var concat = require('gulp-concat'); +var git = require('gulp-git'); var gulp = require('gulp'); var gulpif = require('gulp-if'); var pug = require('gulp-pug'); @@ -18,7 +19,8 @@ var enabled = { maps: argv.production, failCheck: !argv.production, prettyPug: !argv.production, - cachify: !argv.production + cachify: !argv.production, + cleanup: argv.production, }; var destination = { @@ -100,6 +102,21 @@ gulp.task('watch',function() { gulp.watch('src/scripts/tutti/**/*.js',['scripts_concat_tutti']); }); +// 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',]); +var tasks = []; +if (enabled.cleanup) tasks.push('cleanup'); +gulp.task('default', tasks.concat(['styles', 'templates', 'scripts', 'scripts_concat_tutti'])); diff --git a/package.json b/package.json index 51ae2ad..caa484c 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-pug": "~3.2.0", "gulp-livereload": "~3.8.1", "gulp-plumber": "~1.1.0",