Commit b5ca84b4 authored by Lily Foster's avatar Lily Foster Committed by Matthieu Coudron
Browse files

npmHooks.npmInstallHook: only overwrite npm cache for `npm pack` rather than for entire hook

parent 3bc05045
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -5,16 +5,14 @@ npmInstallHook() {

    runHook preInstall

    # `npm pack` writes to cache
    npm config delete cache

    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) | join("\n")' <<< "$(npm pack --json --dry-run --loglevel=warn --no-foreground-scripts ${npmWorkspace+--workspace=$npmWorkspace} $npmPackFlags "${npmPackFlagsArray[@]}" $npmFlags "${npmFlagsArray[@]}")")
    done < <(@jq@ --raw-output '.[0].files | map(.path) | join("\n")' <<< "$(npm_config_cache="$HOME/.npm" npm pack --json --dry-run --loglevel=warn --no-foreground-scripts ${npmWorkspace+--workspace=$npmWorkspace} $npmPackFlags "${npmPackFlagsArray[@]}" $npmFlags "${npmFlagsArray[@]}")")

    # Based on code from Python's buildPythonPackage wrap.sh script, for
    # supporting both the case when makeWrapperArgs is an array and a