Wildcard/pattern cache_directories




I’ve got a project in CircleCI which contains a few node projects within it.

At the moment our npm install step takes a long time (10mins) and I’d like to drastically reduce this with caching. However I’d rather not type out all the node_modules directories by hand, as these will change over time.

Is it possible to define a line in cache_directories to pick up any and all node_modules folders in the project and cache them?

Something like:

      - */node_modules




Also interested in this (for the same reason)


We also have a few repositories that are structured like this.


There’s a not-inelegant workaround that takes advantage of shell command wildcards.

Generate checksums of all files declaring your dependencies (this example is for SBT projects, but I’m sure it may apply to similar build systems) immediately following your checkout command:

# Elided.
- checkout
- run: find . \( -name "dependencies.sbt" -o -name "plugins.sbt" \) -exec shasum {} \; > checksums
- *use_restore_cache
# Elided.

Then make the cache key include an aggregate checksum of that result:

- v1-{{ arch }}-{{checksum "checksums" }}

Equivalent to the feature request, easily understood, and adds little cruft to the configuration.