Created
February 9, 2018 09:10
-
-
Save Tenderfeel/6ba211be4340e90a51b4dbcb78de49d8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs'), | |
del = require('del'); | |
gulp.task('clean', function(done) { | |
var files = fs.readdirSync('dist'); | |
var targets = []; | |
if(files.length) { | |
targets.push('dist/*'); | |
} | |
if(fs.existsSync('your-file.js')) { | |
targets.push('your-file.js'); | |
} | |
if(targets.length) { | |
return del(targets); | |
} else { | |
done(); | |
console.log('Delete directory and file not found.'); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment