Files
phaer e2013a5096 importNpmLock: fix check for .bin in linkNodeModulesHook
node_modules/.bin/ is expected to be (symlink to) a directory rather
than a regular file, so we check for that.

This seems to work for pre-existing directories as well as those
we link to the store (managed & unmanaged in the hooks terminology).

I am not entirely sure whether the original check was simply a typo
or intentional for some use-cases.
2025-01-10 12:37:32 +01:00

32 lines
763 B
Bash

linkNodeModulesHook() {
echo "Executing linkNodeModulesHook"
runHook preShellHook
if [ -n "${npmRoot-}" ]; then
pushd "$npmRoot"
fi
@nodejs@ @script@ @storePrefix@ "${npmDeps}/node_modules"
if test -d node_modules/.bin; then
export PATH=$(readlink -f node_modules/.bin):$PATH
fi
if [ -n "${npmRoot-}" ]; then
popd
fi
runHook postShellHook
echo "Finished executing linkNodeModulesShellHook"
}
if [ -z "${dontLinkNodeModules:-}" ] && [ -z "${shellHook-}" ]; then
echo "Using linkNodeModulesHook shell hook"
shellHook=linkNodeModulesHook
fi
if [ -z "${dontLinkNodeModules:-}" ]; then
echo "Using linkNodeModulesHook preConfigure hook"
preConfigureHooks+=(linkNodeModulesHook)
fi