1 # shellcheck shell=bash
4 echo "Executing yarnInstallHook"
8 local -r packageOut
="$out/lib/node_modules/$(@jq@ --raw-output '.name' ./package.json)"
20 local -r tmpDir
="$(mktemp -d)"
22 # yarn pack does not work at all with bundleDependencies.
23 # Since we are imediately unpacking, we can just remove them from package.json
24 # This will NOT be fixed in yarn v1: https://github.com/yarnpkg/yarn/issues/6794
25 mv .
/package.json
"$tmpDir/package.json.orig"
26 # Note: two spellings are accepted, 'bundleDependencies' and 'bundledDependencies'
27 @jq@
'del(.bundleDependencies)|del(.bundledDependencies)' "$tmpDir/package.json.orig" > .
/package.json
29 # TODO: figure out a way to avoid redundant compress/decompress steps
31 --filename "$tmpDir/yarn-pack.tgz" \
34 tar xzf
"$tmpDir/yarn-pack.tgz" \
36 --strip-components 1 \
39 mv "$tmpDir/package.json.orig" .
/package.json
41 nodejsInstallExecutables .
/package.json
43 nodejsInstallManuals .
/package.json
45 local -r nodeModulesPath
="$packageOut/node_modules"
47 if [ ! -d "$nodeModulesPath" ]; then
48 if [ -z "${yarnKeepDevDeps-}" ]; then
49 # Yarn has a 'prune' command, but it's only a stub that directs you to use install
58 echo "ERROR: yarn prune step failed"
60 echo 'If yarn tried to download additional dependencies above, try setting `yarnKeepDevDeps = true`.'
67 find node_modules
-maxdepth 1 -type d
-empty -delete
69 cp -r node_modules
"$nodeModulesPath"
74 echo "Finished yarnInstallHook"
77 if [ -z "${dontYarnInstall-}" ] && [ -z "${installPhase-}" ]; then
78 installPhase
=yarnInstallHook