From 00b5cda3e3295bd55f3886d25cc5a8f879a64b5a Mon Sep 17 00:00:00 2001 From: green961 <81228933+green961@users.noreply.github.com> Date: Thu, 10 Aug 2023 23:11:51 +0800 Subject: [PATCH] fix: replace reduce with flatMap (#106) --- lib/index.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/index.js b/lib/index.js index 52e9ea6..2de436c 100644 --- a/lib/index.js +++ b/lib/index.js @@ -31,11 +31,7 @@ const getPathInfo = (cmd, { if (isWindows) { 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 - }, []) + const pathExt = pathExtExe.split(optDelimiter).flatMap((item) => [item, item.toLowerCase()]) if (cmd.includes('.') && pathExt[0] !== '') { pathExt.unshift('') }