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

glob based matching broken on Windows #15

Open
Marcus10110 opened this issue Jan 4, 2023 · 0 comments · May be fixed by #16
Open

glob based matching broken on Windows #15

Marcus10110 opened this issue Jan 4, 2023 · 0 comments · May be fixed by #16

Comments

@Marcus10110
Copy link

Quite simply, * and ** based matches fail to work on windows.

Ironically, this actually prevents the tests from running on windows, because the '*' character is used to find tests.

To reproduce the failure, simply modify the jake file to explicitly run the test file my name by editing this line:

this.testFiles.include('test/*.js');

and replace with this.testFiles.include('test/filelist.js');

Once the tests actually run on windows, the following test output will be displayed:

> yarn test
yarn run v1.22.17
$ jake test
Starting 'test'...
jake aborted.
AssertionError [ERR_ASSERTION]: 0 == 2
    at Task.path separator can be used by exclude (C:\Users\markg\Software\filelist\test\filelist.js:32:12)
    at Task.action (C:\Users\markg\Software\filelist\node_modules\jake\lib\test_task.js:173:22)
    at Task.run (C:\Users\markg\Software\filelist\node_modules\jake\lib\task\task.js:325:29)
    at processImmediate (internal/timers.js:464:21)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

The root problem is the use of path.normalize here, on the query, right before passing the pattern to minimatch:

pat = path.normalize(pat);

A quick test shows removing this normalization causes tests to pass. However, I think normalization is still needed for handling other path fixups, and instead the same fixup used by globSync should be used after normalization to switch back to Unix path separators.

I'll get a PR open shortly.

Marcus10110 added a commit to Marcus10110/filelist that referenced this issue Jan 4, 2023
The pattern is normalized right before being passed to minimatch, which uses glob to check for directory matches.
This converts Unix path separators back to Windows separators, so the regex replace is needed to convert them back to unix separators, as required by minimatch.
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.

1 participant