Debug build cache (Node)?

Hi @axwalker,

I believe @jake’s suggestion is to put things you need cached in the directory already set in $XDG_CACHE_HOME, since we do save that cache. For example, if your node_modules directory isn’t at the root of your project (which we will cache automatically) and instead is in some subfolder, you can still use $XDG_CACHE_HOME to cache it.

An example would be doing something like this as a wrapper to your build script:

#!/usr/bin/env bash

# If we have a cache directory, use it. If not, create it
cache_dir="${XDG_CACHE_HOME}/node_modules"
main_dir="my-app/some-subfolder/node_modules"
mkdir -p "${cache_dir}"

mv "${cache_dir}" "${main_dir}"

# call your normal build script
my-build-script.sh

# put the updated node_modules directory back in the cache so the next build can use it
mv "${main_dir}" "${cache_dir}"
1 Like