npmConfigHook: always make cache writable when using cache v2
This commit is contained in:
@@ -28,29 +28,27 @@ npmConfigHook() {
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -e "$npmDeps/cache_version" ]]; then
|
||||
local -r cacheVersion=$(cat "$npmDeps/cache_version")
|
||||
else
|
||||
local -r cacheVersion="1"
|
||||
fi
|
||||
|
||||
# Only run this in buildNpmPackage, this is just for a nicer error message; we trust that
|
||||
# people using the setup hook directly also know how FODs work. ;)
|
||||
if [[ -n ${NIX_NPM_CACHE_VERSION+x} ]]; then
|
||||
if [[ -e "$npmDeps/cache_version" ]]; then
|
||||
local -r cacheVersion=$(cat "$npmDeps/cache_version")
|
||||
else
|
||||
local -r cacheVersion="1"
|
||||
fi
|
||||
if [[ -n ${NIX_NPM_CACHE_VERSION+x} ]] && [[ $NIX_NPM_CACHE_VERSION != $cacheVersion ]]; then
|
||||
echo
|
||||
echo "ERROR: npmDepsHash is out of date"
|
||||
echo
|
||||
echo "The cache version in the arguments to buildNpmPackage ($NIX_NPM_CACHE_VERSION) is not the same as the one in $npmDeps ($cacheVersion)."
|
||||
echo
|
||||
echo "To fix the issue:"
|
||||
echo '1. Use `lib.fakeHash` as the npmDepsHash value'
|
||||
echo "2. Build the derivation and wait for it to fail with a hash mismatch"
|
||||
echo "3. Copy the 'got: sha256-' value back into the npmDepsHash field"
|
||||
echo
|
||||
|
||||
if [[ $NIX_NPM_CACHE_VERSION != $cacheVersion ]]; then
|
||||
echo
|
||||
echo "ERROR: npmDepsHash is out of date"
|
||||
echo
|
||||
echo "The cache version in the arguments to buildNpmPackage ($NIX_NPM_CACHE_VERSION) is not the same as the one in $npmDeps ($cacheVersion)."
|
||||
echo
|
||||
echo "To fix the issue:"
|
||||
echo '1. Use `lib.fakeHash` as the npmDepsHash value'
|
||||
echo "2. Build the derivation and wait for it to fail with a hash mismatch"
|
||||
echo "3. Copy the 'got: sha256-' value back into the npmDepsHash field"
|
||||
echo
|
||||
|
||||
exit 1
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
|
||||
local -r cacheLockfile="$npmDeps/package-lock.json"
|
||||
@@ -103,7 +101,11 @@ npmConfigHook() {
|
||||
|
||||
local cachePath
|
||||
|
||||
if [ -z "${makeCacheWritable-}" ]; then
|
||||
# When a given cache key has multiple entries (which is the case with
|
||||
# cache version 2), npm always needs to write to the cache.
|
||||
#
|
||||
# TODO(winter): report upstream?
|
||||
if [ -z "${makeCacheWritable-}" ] && (( cacheVersion == 1 )); then
|
||||
cachePath="$npmDeps"
|
||||
else
|
||||
echo "Making cache writable"
|
||||
|
||||
Reference in New Issue
Block a user