volta-cli/volta

Improve detection of "root" project when inside `node_modules`

Open

#950 建立於 2021年2月25日

在 GitHub 查看
 (6 留言) (0 反應) (0 負責人)Rust (8,309 star) (189 fork)batch import
enhancementgood first issue

描述

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.

貢獻者指南

Improve detection of "root" project when inside `node_modules` · volta-cli/volta#950 | Good First Issue