I'm shocked I'm only now hitting this after using this library since it basically launched, but here we are. 😅
I have premove embedded in a pipeline where a directory gets purged on each run. (Out of my control but I'm back in Gulp land.) I pointed premove at that directory, added it as a step and moved on.
However I quickly hit an issue — as documented if premove does not find the file or directory it returns a bare false. But that's surprising when you're using the async function — I expected a Promise! This whole time I did actually think it returned Promise<false> but maybe my previous uses weren't so sensitive to that. Gulp however doesn't recognize that false as a valid "step complete" signal and locks up.
I can (and will) certainly just code around this, but it did make me wonder if the async function should always return a Promise so other code assuming it's truly an async function won't get tripped up. FWIW the native fsPromise.rmDir and fsPromise.rmdo return Promises independent of directory/file existence.
Thanks for raising this. Yeah, weird choice 😅
I'll cut a 4.0 that has both modes return a boolean, indicating whether or not the path existed. The async will be Promise<boolean> (truly).
I'm shocked I'm only now hitting this after using this library since it basically launched, but here we are. 😅
I have
premove
embedded in a pipeline where a directory gets purged on each run. (Out of my control but I'm back in Gulp land.) I pointedpremove
at that directory, added it as a step and moved on.However I quickly hit an issue — as documented if
premove
does not find the file or directory it returns a barefalse
. But that's surprising when you're using theasync
function — I expected aPromise
! This whole time I did actually think it returnedPromise<false>
but maybe my previous uses weren't so sensitive to that. Gulp however doesn't recognize thatfalse
as a valid "step complete" signal and locks up.I can (and will) certainly just code around this, but it did make me wonder if the async function should always return a Promise so other code assuming it's truly an async function won't get tripped up. FWIW the native
fsPromise.rmDir
andfsPromise.rm
do return Promises independent of directory/file existence.