-
-
Notifications
You must be signed in to change notification settings - Fork 39
Description
normalizePath is used to normalize file URLs, buffers, and irregular strings into valid paths.
Part of this normalization is converting the path into an absolute one via path.resolve. Unfortunatly, normalizePath is not aware of contexts, resulting in path.resolve always using the default context's PWD to resolve relative paths. This was originally pointed out by @jeff-hykin in #261:
One thing though, a bug that would be my first actual PR: I think
resolveneeds to usethisto get the pwd. E.g. this bit of code Right now its always using the default context's pwd. Also, similar bug,normalizePathin utils needsthisso it can pass it toresolve. Then, because of that, a lot ofnormalizePathandresolvecalls need to be changed toresolve.call(this, x).
Additionally, calls to normalizePath are duplicated acros multiple code paths. For example, take lstat:
lstat
├ normalizePath
├ realpath
│ ├ normalizePath
│ └ _resolve
│ └ resolveMount
│ └ normalizePath
└ resolveMount
└ normalizePath
That's 4 calls to normalizePath in the best case. Resolving parent directories and symlinks in _resolve further increases the number of calls.
In order to properly fix this problem, the path resolution will be cleaned up to handle everything at once without a mess of function calls and properly handle PWDs.