cache Usage and options

Temporarily remove a folder (or folders) and restore it when you need it again.

Warning: this program is still in beta and subject to change. It’s use in scripts is highly unrecommended.

Usage

cache <folder 1> <folder 2> <...>

cache takes any number of arguments. Each argument represents a folder in the current directory (currently only supporting one level deep namespacing). These folders will be removed from the current working directory and stored elsewhere on the computer until you need them again.

cache <option>

cache supports the following options:

Examples

Example 1: Temporarily removing the node_modules folder

This very task is why this program was written. I have often needed to remove the node_modules to link repos in an application, and then later need to restore them to run tests in that repo.

To cache the folder run:

cache node_modules

We can now do whatever tasks need to be done without that folder there. When we are ready to have the node_modules back in the repo, we can simply invoke:

cache --restore node_modules

This is much quicker than running npm install, and a lot more efficient on resources to do so. I have used this program among the most in my toolset for this very task.

Example 2: Knowing if the current working directory has any cached folders

I sometimes can’t remember when I last cached a folder, or if I have just never done a npm install on that repo yet. The following command helps us decide.

cache --show

This will output something to the following:

Files for <project> were cached on Fri Nov 16 07:45:23 MST 2018
node_modules