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 URL as options.cwd? #176

Closed
fisker opened this issue May 12, 2021 · 2 comments · Fixed by #201
Closed

Accept URL as options.cwd? #176

fisker opened this issue May 12, 2021 · 2 comments · Fixed by #201

Comments

@fisker
Copy link
Collaborator

fisker commented May 12, 2021

import globby from 'globby';
const dir = new URL('./src', import.meta.url);

console.log(await globby('*', {cwd: dir}));

// TypeError: Expected `cwd` to be of type `string` but received type `object`

Currently, I have to

+ import {fileURLToPath} from 'node:url';
  import globby from 'globby';
  const dir = new URL('./src', import.meta.url);

- console.log(await globby('*', {cwd: dir}));
+ console.log(await globby('*', {cwd: fileURLToPath(dir)}));
@fisker fisker changed the title Accept URL as cwd? Accept URL as options.cwd? May 12, 2021
@sindresorhus
Copy link
Owner

Yup. I want to support URL anywhere I accept paths.

@TriMoon
Copy link

TriMoon commented Mar 28, 2022

@fisker

// TypeError: Expected cwd to be of type string but received type object

I was just browsing in this repo and came accross this and wanted to comment.
Not sure how you guys implemented this yet but why not do something like this everywhere a URL is accepted?

if (cwd instanceof URL){
  cwd = cwd.toString()
}

eg. check if it is an URL object and if so use it's .toString() method to convert it into a string...

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