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

2.2.x cannot convert absolute path with files option #15

Closed
yhatt opened this issue Jan 20, 2019 · 2 comments
Closed

2.2.x cannot convert absolute path with files option #15

yhatt opened this issue Jan 20, 2019 · 2 comments

Comments

@yhatt
Copy link
Contributor

yhatt commented Jan 20, 2019

Hi. I'm using dir-glob through globby in my project.

I found a regression in the case of passing absolute path with files option. It works correctly in v2.0.0, but v2.2.1 does not return globbed path.

const dirGlob = require('dir-glob')
dirGlob(['/app/tmp'], { files: ['*.txt'] }).then(globs => console.log(globs))

// dir-glob@2.0.0 returns ['/app/tmp/**/*.txt']
// dir-glob@2.2.1 returns ['/app/tmp/']

See also RunKit: https://runkit.com/yhatt/5c44923f09b0c40012f808d1

Perhaps it might come from updated getPath.

const getPath = (filepath, cwd) => path.join(cwd, filepath[0] === '!' ? filepath.slice(1) : filepath);

path.join() returns just concatenated path, and not consider absolute path.

join('/foo/bar', '/foo') // => "/foo/bar/foo"

Apparently, tests did not cover the case of passing absolute path. I want to work on it.

@kevva
Copy link
Owner

kevva commented Jan 20, 2019

Thanks for reporting @yhatt. It was indeed a regression in the getPath function. I added a check for absolute paths which ignores joining them with cwd.

Did a release with the fix (2.2.2).

@yhatt
Copy link
Contributor Author

yhatt commented Jan 20, 2019

Thank you so much! I've confirmed to work it with absolute path, and my project's test have passed by updating dir-glob.

@yhatt yhatt changed the title 2.2.0 cannot convert absolute path with files option 2.2.x cannot convert absolute path with files option Jan 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants