Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ensureDir cannot catch NotFound error from dntShim.lstat #94

Closed
hyp3rflow opened this issue Mar 4, 2022 · 1 comment · Fixed by #95
Closed

ensureDir cannot catch NotFound error from dntShim.lstat #94

hyp3rflow opened this issue Mar 4, 2022 · 1 comment · Fixed by #95

Comments

@hyp3rflow
Copy link
Contributor

NotFound error from dntShim.Deno.lstat is node one, so it is not same as dntShim.Deno.errors.NotFound

export async function ensureDir(dir) {
    try {
        const fileInfo = await dntShim.Deno.lstat(dir);
        if (!fileInfo.isDirectory) {
            throw new Error(`Ensure path exists, expected 'dir', got '${getFileInfoType(fileInfo)}'`);
        }
    }
    catch (err) {
        if (err instanceof dntShim.Deno.errors.NotFound) { // <- Always false
            await dntShim.Deno.mkdir(dir, { recursive: true });
            return;
        }
        throw err;
    }
}
@hyp3rflow
Copy link
Contributor Author

duplicated #87?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant