Skip to content

Async function call does not always return a Promise #4

@rdmurphy

Description

@rdmurphy

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.rm do return Promises independent of directory/file existence.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions