Skip to content

fix: avoid duplicate lowercase PATHEXT candidates - #186

Open
yqia03 wants to merge 1 commit into
npm:mainfrom
yqia03:fix/lowercase-pathext-duplicates
Open

yqia03 wants to merge 1 commit into
npm:mainfrom
yqia03:fix/lowercase-pathext-duplicates

Conversation

@yqia03

@yqia03 yqia03 commented Nov 15, 2026

Copy link
Copy Markdown

On Windows, a lowercase PATHEXT entry is expanded twice: .cmd becomes ['.cmd', '.cmd']. With an extensionless command and all: true, both the asynchronous and synchronous APIs therefore return the same executable path twice and repeat its executable check.

Append the lowercase alternative only when it differs from the original extension. Keep the original-first ordering and distinct case alternatives required for case-sensitive Windows directories (#57, #100).

Tests cover the duplicate result using a real fixture through the existing Windows platform harness, plus distinct uppercase/lowercase matches and their order using a case-sensitive executable-check mock. The duplicate-result regression fails for both APIs on the original source and passes with this change.

Validation: both test files pass on Node 22.23.5 and 26.8.1, with 100% statement, branch, function, and line coverage. ESLint and git diff --check pass. Windows behavior was tested using platform isolation on macOS; no native Windows run was performed locally.

npm test exits 1 only in postlint / template-oss-check, which asks for updates to five generated .github files. The template-check output is identical on untouched main (2009c9d) and this branch. Generated files are unchanged, as requested by CONTRIBUTING.md.

The change is confined to constructing Windows extension candidates. Existing distinct candidates and their order remain intact; the commit can be reverted independently without a migration.

AI assistance: OpenAI Codex discovered, prepared, tested, and independently reviewed this patch under the account owner's authorization. The account owner has not personally reviewed or tested it.

@yqia03
yqia03 requested a review from a team as a code owner November 15, 2026 17:02
Copilot AI balanced review requested due to automatic review settings November 15, 2026 17:02

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

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 this pull request may close these issues.

2 participants