This action generates a cache key out of the package.json and package-lock.json.
The Problem: The package-lock.json contains the package version. If that versions changes the hash of the file changes. To avoid getting a new cache key, when your package version changes this actions strips the version.
It accepts a package.json and package-lock.json file path. Nothing special is happening. Just replacing the version in package-lock and getting a hash back.
- reads json files
- grab package name from package.json
- search for that package name and its following version key in package-lock.json
- replaces all whitespaces, tabs and newlines and the version number with empty string
- hashes the file content and output it as cache key
- packageJSON: path to package.json file. Default
./package.json
. - packageLockJSON: path to package-lock.json file. Default
./package-lock.json
.
- cacheKey: The generated hash over package-lock.json without version number.
uses: codaline-io/[email protected]
with:
packageJSON: custom-sub-folder/package-test.json
packageLockJSON: custom-sub-folder/my-lock-file.json