Gulp: added 'cleanup' task that erases all gulp-generated files.

This runs automatically when using --production
This commit is contained in:
2017-09-28 15:35:15 +02:00
parent 5c58ced224
commit 4fa18d4454
2 changed files with 20 additions and 2 deletions

View File

@@ -2,6 +2,7 @@ var argv = require('minimist')(process.argv.slice(2));
var autoprefixer = require('gulp-autoprefixer'); var autoprefixer = require('gulp-autoprefixer');
var chmod = require('gulp-chmod'); var chmod = require('gulp-chmod');
var concat = require('gulp-concat'); var concat = require('gulp-concat');
var git = require('gulp-git');
var gulp = require('gulp'); var gulp = require('gulp');
var gulpif = require('gulp-if'); var gulpif = require('gulp-if');
var jade = require('gulp-jade'); var jade = require('gulp-jade');
@@ -18,7 +19,8 @@ var enabled = {
maps: argv.production, maps: argv.production,
failCheck: argv.production, failCheck: argv.production,
prettyPug: !argv.production, prettyPug: !argv.production,
liveReload: !argv.production liveReload: !argv.production,
cleanup: argv.production,
}; };
var destination = { var destination = {
@@ -99,6 +101,21 @@ gulp.task('watch',function() {
gulp.watch('src/scripts/tutti/*.js',['scripts_tutti']); gulp.watch('src/scripts/tutti/*.js',['scripts_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 // Run 'gulp' to build everything at once
gulp.task('default', ['styles', 'templates', 'scripts', 'scripts_tutti']); var tasks = [];
if (enabled.cleanup) tasks.push('cleanup');
gulp.task('default', tasks.concat(['styles', 'templates', 'scripts', 'scripts_tutti']));

View File

@@ -13,6 +13,7 @@
"gulp-chmod": "~1.3.0", "gulp-chmod": "~1.3.0",
"gulp-concat": "~2.6.0", "gulp-concat": "~2.6.0",
"gulp-if": "^2.0.1", "gulp-if": "^2.0.1",
"gulp-git": "~2.4.2",
"gulp-jade": "~1.1.0", "gulp-jade": "~1.1.0",
"gulp-livereload": "~3.8.1", "gulp-livereload": "~3.8.1",
"gulp-plumber": "~1.1.0", "gulp-plumber": "~1.1.0",