Self-assigning. I'll take this up when I have time. This is a pure refactor to reduce repeated code blocks.
I noticed we have 3 blocks of code where we push the match (where.push(attempt)...where = attempt): 2 inside of the win section, 1 in the unix section. We can easily combine these.
- Make the path-ext array, but initialize it to
[] for unix and to [''].concat(splitPath()) for Windows
- Always iterate over the path-ext array. The only member is the empty string on unix, so nothing should change.