A gulp plugin for removing files and folders.
Removes files and folders.
Install with npm.
npm install --save-dev gulp-clean
var gulp = require'gulp';var clean = require'gulp-clean';gulptask'default'return gulpsrc'app/tmp' read: falsepipeclean;;
Option read:false prevents gulp from reading the contents of the file and makes this task a lot faster. If you need the file and its contents after cleaning in the same stream, do not set the read option to false.
var gulp = require'gulp';var clean = require'gulp-clean';gulptask'default'return gulpsrc'app/tmp/index.js'pipecleanforce: truepipegulpdest'dist';;
Clean as a dependency:
var gulp = require'gulp';var clean = require'gulp-clean';gulptask'clean-scripts'return gulpsrc'app/tmp/*.js' read: falsepipeclean;;gulptask'scripts' 'clean-scripts'gulpsrc'app/scripts/*.js'pipegulpdest'app/tmp';;gulptask'default' 'scripts';
Make sure to return the stream so that gulp knows the clean task is asynchronous and waits for it to terminate before starting the dependent one.
MIT @ Peter Vilja