Restore node_modules only if package-lock.json
has changed before previous restoration.
npx ci-once
npm install -g npm-ci-once
And then use:
npm-ci-once
See the tiny implementation: src/main.js.
-
Restoration: To restore, this script spawns a default shell to execute
npm ci
. -
Skipping unnecessary restoration: After restoration, this script writes SHA-256 hash value of
package-lock.json
to a file undernode_modules
. This scripts also checks if the hash value has changed or not.