to-absolute-glob icon indicating copy to clipboard operation
to-absolute-glob copied to clipboard

Cannot create linux glob paths on windows machine even when specifying root dir

Open dsherret opened this issue 7 years ago • 3 comments

On windows machines, the following code:

toAbsoluteGlob("**/*.txt", { cwd: "/", root: "/" }))

Will output the following:

C:/**/*.txt

Expected: /**/*.txt

I'm thinking that perhaps the following:

if (rootDir) {
  rootDir = unixify(rootDir);
  if (process.platform === 'win32' || !isAbsolute(rootDir)) {
    rootDir = unixify(path.resolve(rootDir));
  }
}

Should maybe be changed to?

if (rootDir) {
  rootDir = unixify(rootDir);
  if (!isAbsolute(rootDir)) {
    rootDir = unixify(path.resolve(rootDir));
  }
}

dsherret avatar Mar 07 '18 20:03 dsherret

See my commit here. This might be considered a change of behaviour, but this allows for linux globs to be created on windows:

https://github.com/dsherret/to-absolute-glob/commit/7ca9987c8f2e96cc2f88dc32bade0df9b8806405

dsherret avatar Mar 07 '18 21:03 dsherret

want to do a PR so we can review?

jonschlinkert avatar Mar 11 '18 05:03 jonschlinkert

@jonschlinkert done. I opened #16.

There was one slight issue with it a day ago on the linux CI, but it's good now.

dsherret avatar Mar 17 '18 02:03 dsherret