I don't understand what i'm doing wrong. I want to clean up my dist/browser
folder, but absolutely noothing happens, not even an error.
const gulp = require("gulp");
const gulpElm = require('gulp-elm');
const clean = require('gulp-clean');
const del = require('del');
gulp.task("clean-dist/browser-folder", () => {
console.log("this gets logged - and nothing happens.");
return gulp.src('dist/**', {read: false})
.pipe(clean({force: true}));
});
// i commented this out but this 2 aproaches below using del module also don't work
// gulp.task("clean-dist/browser-folder", () => {
// return del([ "dist/browser"], {force:true});
// });
// gulp.task("clean-dist/browser-folder", async () => {
// return await del([ "dist/browser/**", "!dist/browser" ], {force:true});
// });
//
gulp.task("default", [ "clean-dist/browser-folder" ]);
Also i used function (){}
instead of lambda
. Exact same result. WTCrap is happening?
All questions i reaserched plus the docs suggest i'm doing things correctly.
Am i missing something very obvious - i'm just blinded to it right now ? Thanks :)
Crap! i found it. So basically my gulp scripts
are in a gulp folder
like so (sorry i forgot to mention this in the question - since i wasn't thinking is somehow relevant) :
rootOfProject/gulp/firstGulpScript.js
rootOfProject/gulp/secondGulpScript.js
// and the cleaning path:
rootOfProject/dist/browser/crap.js
I need multiple gulp script files since is a project with multiple apps which require separate compilation in separate locations and such. Seemed nicer to split each app in it's own gulp file. Thinking back at this it might not have been the brightest idea.
Now what happens, in my clean() task to delete crap.js
i have :
return del([ "dist/browser/crap.js"], { force : true });
But gulp looks into:
rootOfProject/gulp/dist/browser/crap.js
- which of course is wrong location.
I am supposed to write this instead:
return del([ "../dist/browser/crap.js"], { force : true });
- note the ../
in front of the path here. As such the new location will be:
rootOfProject/dist/browser/crap.js
- which is the correct location to start cleaning.
There was nothing to clean in rootOfProject/gulp/dist ..
that's why i wasn't getting any errors. The task was running just fine, but nothing was beeing deleted form dist/... With no errors things were even more confusing
This hole mess lost me 2-3 hours..
Hopefully if somebody finds an issue like this they will be more careful about the path specified - when the gulp script file is not in the root of the project.