depot/third_party/nixpkgs/pkgs/development/tools/pnpm/fetch-deps/pnpm-config-hook.sh
Default email bcb2f287e1 Project import generated by Copybara.
GitOrigin-RevId: d603719ec6e294f034936c0d0dc06f689d91b6c3
2024-06-20 20:27:18 +05:30

40 lines
782 B
Bash

# shellcheck shell=bash
pnpmConfigHook() {
echo "Executing pnpmConfigHook"
if [ -n "${pnpmRoot-}" ]; then
pushd "$pnpmRoot"
fi
if [ -z "${pnpmDeps-}" ]; then
echo "Error: 'pnpmDeps' must be set when using pnpmConfigHook."
exit 1
fi
echo "Configuring pnpm store"
export HOME=$(mktemp -d)
export STORE_PATH=$(mktemp -d)
cp -Tr "$pnpmDeps" "$STORE_PATH"
chmod -R +w "$STORE_PATH"
pnpm config set store-dir "$STORE_PATH"
echo "Installing dependencies"
pnpm install --offline --frozen-lockfile --ignore-script
echo "Patching scripts"
patchShebangs node_modules/{*,.*}
if [ -n "${pnpmRoot-}" ]; then
popd
fi
echo "Finished pnpmConfigHook"
}
postConfigureHooks+=(pnpmConfigHook)