Refactor to remove unnecessary entries in paths array

The latest backwards-compatibility commit ended up adding in `fs.pathJoin(dir, basename)` three times for each `basename`.

This commit adds it for each `basename` instead of each `extension` and `basename`