feat: add support for process.env.npminstall_cache #471
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
现状
npminstall 内置了 tarball 的缓存能力,默认的缓存地址为
~/.npminstall_tarball
. npminstall 不支持通过--cache
配置缓存目录的位置,但支持通过process.env.npm_config_cache
进行配置。我们的预期
预期能通过配置文件或环境变量修改 npminstall 缓存的位置,且缓存的目录能与 npm 区分开
遇到的问题
如果使用
npm_config_cache
配置 npminstall 的缓存位置,会同时修改 npm 的缓存位置,导致两个缓存总是位于同一个父目录修改方法
新增
process.env.npminstall_cache
配置,允许配置缓存位置,且能够和 npm 的缓存目录分隔开。 (或者其他方式,能满足需求即可)