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

Windows absolute paths ignores root path #61

Closed
marcusstenbeck opened this issue Mar 7, 2013 · 2 comments
Closed

Windows absolute paths ignores root path #61

marcusstenbeck opened this issue Mar 7, 2013 · 2 comments

Comments

@marcusstenbeck
Copy link

The fix from #53 causes paths prefixed with / to not mount the path on top of the passed in root path.

When I pass in { root: 'c:\foo' } or something like that, and try to match /bar i will end up with c:\bar instead of what I expect, which is c:\foo\bar. Or at least I've understood that's how it works from reading the documentation.

  • root The place where patterns starting with / will be mounted onto. Defaults to path.resolve(options.cwd, "/") (/ on Unix systems, and C:\ or some such on Windows.)
path.resolve('/foo/bar', './baz')
// returns
'/foo/bar/baz'

path.resolve('/foo/bar', '/tmp/file/')
// returns
'/tmp/file'

path.resolve('wwwroot', 'static_files/png/', '../gif/image.gif')
// if currently in /home/myself/node, it returns
'/home/myself/node/wwwroot/static_files/gif/image.gif'

Passing in a leading / to any argument of path.resolve() seems to mount it at root. My suggestion is to not try and do too much to Windows absolute paths in prefix.

It all works for me when I uncomment these lines, but I understand it breaks the previous issue: https://github.com/isaacs/node-glob/blob/master/glob.js#L369-L370

@kschzt
Copy link

kschzt commented May 29, 2013

is this the same issue? the absolute alternative below returns nothing:

var g = require('glob')

console.log(process.cwd())
g('folder/**/*.js', { cwd: process.cwd(), root: process.cwd() }, function(e, ps) {
    console.log('non-absolute', ps)
})

g('/folder/**/*.js', { cwd: process.cwd(), root: process.cwd() }, function(e, ps) {
    console.log('absolute', ps)
})

@sakari
Copy link

sakari commented May 29, 2013

I had a peek at this but the tests in master do not pass on windows 8 which makes it somewhat harder to start digging this.

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.

3 participants