Skip to content

Commit

Permalink
[Deps] update glob to v10 to fix ignore options on windows
Browse files Browse the repository at this point in the history
The current version of `glob` returns paths always with forward slashes, even on windows. This causes the `dotignore` `Matcher` to never match the paths on windows, because it expects backslashes on windows. This means that the `--ignore` and `--ignore-pattern` options do not work properly on windows.

This is fixed in a newer version of glob (not sure which specific version). However, the newer version returns paths in an undefined order, so a `sort()` is now necessary.

This issue is already covered by existing test cases (test/ignore-pattern.js), that are currently failing when they are ran on windows. For example: `.\node_modules\.bin\tap test/*.js`. However, an additional fix is needed to make these tests pass (see next commit).
  • Loading branch information
Joris-van-der-Wel committed Jan 9, 2024
1 parent 886b156 commit 5c26250
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions bin/tape
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,18 @@ var files = opts._.reduce(function (result, arg) {
throw new TypeError('unknown error: glob.sync("' + arg + '") did not return an array or throw. Please report this.');
}

// Stable execution order is desirable for a test runner.
// However, newer versions of "glob" no longer sort the output.
globFiles.sort(function (a, b) {
// replace backslashes with slashes for the sort, so that the order is stable
// between linux and windows.
var pathA = a.replace(/\\/g, '/');
var pathB = b.replace(/\\/g, '/');
if (pathA < pathB) { return -1; }
if (pathA > pathB) { return 1; }
return 0;
});

return result.concat(globFiles);
}
return result.concat(arg);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"dotignore": "^0.1.2",
"for-each": "^0.3.3",
"get-package-type": "^0.1.0",
"glob": "^7.2.3",
"glob": "^10.3.10",
"has-dynamic-import": "^2.0.1",
"hasown": "^2.0.0",
"inherits": "^2.0.4",
Expand Down

0 comments on commit 5c26250

Please sign in to comment.