From 5c262509fc8cd06a3ee80fd7a71abd666c5d56da Mon Sep 17 00:00:00 2001 From: Joris van der Wel Date: Sun, 7 Jan 2024 19:53:10 +0100 Subject: [PATCH] [Deps] update glob to v10 to fix ignore options on windows 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). --- bin/tape | 12 ++++++++++++ package.json | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/bin/tape b/bin/tape index 3b41be76..338b37bd 100755 --- a/bin/tape +++ b/bin/tape @@ -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); diff --git a/package.json b/package.json index 62ea4a7e..d71a5d0f 100644 --- a/package.json +++ b/package.json @@ -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",