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

Accept file URL instances #36

Open
jaydenseric opened this issue Jun 11, 2021 · 2 comments
Open

Accept file URL instances #36

jaydenseric opened this issue Jun 11, 2021 · 2 comments

Comments

@jaydenseric
Copy link

Currently, the makeDir function doesn't accept a file URL instance:

import makeDir from 'make-dir';

await makeDir(new URL('foo/', import.meta.url));

Results in the following error:

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received an instance of URL

This makes make-dir harder to work with within Node.js ESM modules.

Users will run into this gotcha more frequently as most Node.js APIs that work with filesystem paths accept file URL instances, including mkdir.

In the meantime, we have to do this workaround:

import { fileURLToPath } from 'url';
import makeDir from 'make-dir';

await makeDir(fileURLToPath(new URL('foo/', import.meta.url)));
@sindresorhus
Copy link
Owner

PR welcome to add it.

@Vivesh2911
Copy link

okey i am here to help you can i try?

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

Successfully merging a pull request may close this issue.

3 participants