-
-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Controlling cache dir with env variable #16
Comments
This has already been asked for: #1 #9 #10. But I'm really happy that more people are opening up issues. I hope this feature gets added, because even if I don't want to use It means that in such cases we cannot store/restore our dependency and app caches in parallel, but in sequence. This adds to build times, which costs money and takes away from our developer productivity. |
There are almost 3.5m of repositories that are (mostly indirectly) dependant on this package. See https://github.com/avajs/find-cache-dir/network/dependents?package_id=UGFja2FnZS0xNTY5NDYwMQ%3D%3D. And this number will only rise in the future because of such major adoptions like babel and eslint. IMO there should be a way to globally control where the cache should be put. Also, as @isaacs said 4 years ago (#1 (comment)), |
Fwiw, the world has changed a bit in the last 4 years. ESM, babel, nyc, jest, lots of other dev tools have followed this pattern. I've been using I'd be happy to +1 an npm rfc to bless the |
Issue
In many cases it is useful to control the cache directory depending on the environment some tool/command is run in.
For example often in local development we want to keep the default
./node_modules/.cache/my-lib
location but in CI/CD pipeline we want to put it in some place we can persist it between runs.It would be good to have an unified way of controlling directory that with env variable.
Env variables seem to be a common way to do that, a lot of projects that use caches support it in similar way (e.g. yarn uses
YARN_CACHE_FOLDER
, npm -NPM_CACHE_LOCATION
).Possible solutions
Single variable for whole
.cache
dirCACHE_DIR=/some/path
will change the destination for all projectsCons:
CACHE_DIR
is definitely a bad name (too general, 100% sure it's already used in many pipelines)Separate variable for each project
When calling
findCacheDir({name: 'foo'})
we would useFOO_CACHE_DIR
.Cons:
name.toUpperCase()
enough?)Every project does it separately
find-cache-dir
doesn't handle the env variables, projects that want to use it handle it on their own.Cons (?):
The text was updated successfully, but these errors were encountered: