| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
This commit adds `convertPathToPattern` to `expand` in `common.js` to fix the handling of glob patterns for Windows file paths. The [switch to fast-glob](shelljs@13cfe8a) broke the handling of paths with backslashes on Windows. This is a limitation of the fast-glob library. From the [README](https://github.com/mrmlnc/fast-glob?tab=readme-ov-file#how-to-write-patterns-on-windows): >Always use forward-slashes in glob expressions (patterns and [ignore](https://github.com/mrmlnc/fast-glob?tab=readme-ov-file#ignore) option). Use backslashes for escaping characters. [...] Use the [.convertPathToPattern](https://github.com/mrmlnc/fast-glob?tab=readme-ov-file#convertpathtopatternpath) package to convert Windows-style path to a Unix-style path. Fixes shelljs#1246
| try { | ||
| ret = glob.sync(convertQuestionMarkForGlob(listEl), globOpts); | ||
| // Call convertPathToPattern to handle paths with backslashes | ||
| // See https://github.com/mrmlnc/fast-glob/blob/096a5b620f4224eb692bd8ff2c8de0e634e50d8e/README.md?plain=1#L658-L682 |
There was a problem hiding this comment.
How about https://github.com/mrmlnc/fast-glob#convertpathtopatternpath instead?
Sorry, something went wrong.
| }); | ||
|
|
||
| test('cp with Windows-style backslash and glob pattern', (t) => { | ||
| const result = shell.cp('test\\resources\\file*.txt', t.context.tmp); |
There was a problem hiding this comment.
I think you will need to wrap this test case with utils.skipOnUnix(t, () => { ... }. Check out test/which.js for an example of how this works.
Sorry, something went wrong.
|
It looks like this is still breaking some other tests on Windows locally (ex: common.js tests for glob syntax, ? for single char in ... and config.globOptions respects nobrace). The former are fixed by swapping the calls to convertPathToPattern and convertQuestionMarkForGlob, but that doesn't fix the latter. I'll need to take a closer look at what's going wrong. |
Sorry, something went wrong.
This commit switches to replacing `\\` in Windows with `/` instead of using `convertPathToPattern`.
| Back | FazBrowse Home | New Git URL |
This PR adds convertPathToPattern to expand in common.js to fix the handling of glob patterns for Windows file paths.
The switch to fast-glob broke the handling of paths with backslashes on Windows.
This is a limitation of the fast-glob library. From the README:
This PR includes tests for expand and cp that include paths with backslashes. Both of these tests fail without the fix and pass once the fix is added.
Fixes #1246