Improve detection of "root" project when inside `node_modules`
#950 建立於 2021年2月25日
描述
When running a shim, Volta will walk up the directory tree to find the closest available package.json file to use as the project, with one exception: When the immediate parent of the directory that contains package.json is node_modules, then we ignore that file. This means when we are inside of our dependencies, if we run a command, we still correctly detect the actual Project root (as opposed to the root of the dependency we are looking at).
Unfortunately, when we are looking at scoped packages (e.g. @babel/core), then the immediate parent is the scope directory, so we think that the root of our project is /project/node_modules/@babel/core, instead of /project. We should also handle the case where the parent is a scoped directory and look one level higher for node_modules.
This may take some design work to make sure that we don't add too much speculative I/O to the project detection process, because it is on the hot path for all commands.