Skip to content

glob based matching broken on Windows #15

@Marcus10110

Description

@Marcus10110

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions