Files
Dark Steveneq 646b892680
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s
push sheeet
2025-10-09 14:15:47 +02:00

50 lines
1.7 KiB
Bash

# shellcheck shell=bash
npmInstallHook() {
echo "Executing npmInstallHook"
runHook preInstall
local -r packageOut="$out/lib/node_modules/$(@jq@ --raw-output '.name' package.json)"
# `npm pack` writes to cache so temporarily override it
while IFS= read -r file; do
local dest="$packageOut/$(dirname "$file")"
mkdir -p "$dest"
cp "${npmWorkspace-.}/$file" "$dest"
done < <(@jq@ --raw-output '.[0].files | map(.path | select(. | startswith("node_modules/") | not)) | join("\n")' <<< "$(npm_config_cache="$HOME/.npm" npm pack --json --dry-run --loglevel=warn --no-foreground-scripts ${npmWorkspace+--workspace=$npmWorkspace} $npmPackFlags "${npmPackFlagsArray[@]}" $npmFlags "${npmFlagsArray[@]}")")
nodejsInstallExecutables "${npmWorkspace-.}/package.json"
nodejsInstallManuals "${npmWorkspace-.}/package.json"
local -r nodeModulesPath="$packageOut/node_modules"
if [ ! -d "$nodeModulesPath" ]; then
if [ -z "${dontNpmPrune-}" ]; then
if ! npm prune --omit=dev --no-save ${npmWorkspace+--workspace=$npmWorkspace} $npmPruneFlags "${npmPruneFlagsArray[@]}" $npmFlags "${npmFlagsArray[@]}"; then
echo
echo
echo "ERROR: npm prune step failed"
echo
echo 'If npm tried to download additional dependencies above, try setting `dontNpmPrune = true`.'
echo
exit 1
fi
fi
find node_modules -maxdepth 1 -type d -empty -delete
cp -r node_modules "$nodeModulesPath"
fi
runHook postInstall
echo "Finished npmInstallHook"
}
if [ -z "${dontNpmInstall-}" ] && [ -z "${installPhase-}" ]; then
installPhase=npmInstallHook
fi