From c3a543e589a3ac7876df0fc6927f24d74065a267 Mon Sep 17 00:00:00 2001 From: Gar Date: Mon, 1 May 2023 10:21:42 -0700 Subject: [PATCH] fix: check lower case extensions in windows (#100) Closes https://github.com/npm/node-which/issues/57 --- lib/index.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/index.js b/lib/index.js index 8de3388..52e9ea6 100644 --- a/lib/index.js +++ b/lib/index.js @@ -29,8 +29,13 @@ const getPathInfo = (cmd, { ] if (isWindows) { - const pathExtExe = optPathExt || ['.EXE', '.CMD', '.BAT', '.COM'].join(optDelimiter) - const pathExt = pathExtExe.split(optDelimiter) + const pathExtExe = optPathExt || + ['.EXE', '.CMD', '.BAT', '.COM'].join(optDelimiter) + const pathExt = pathExtExe.split(optDelimiter).reduce((acc, item) => { + acc.push(item) + acc.push(item.toLowerCase()) + return acc + }, []) if (cmd.includes('.') && pathExt[0] !== '') { pathExt.unshift('') }