depot/pkgs/build-support/node/build-npm-package/hooks/npm-build-hook.sh
Luke Granger-Brown 57725ef3ec Squashed 'third_party/nixpkgs/' content from commit 76612b17c0ce
git-subtree-dir: third_party/nixpkgs
git-subtree-split: 76612b17c0ce71689921ca12d9ffdc9c23ce40b2
2024-11-10 23:59:47 +00:00

38 lines
1.2 KiB
Bash

# shellcheck shell=bash
npmBuildHook() {
echo "Executing npmBuildHook"
runHook preBuild
if [ -z "${npmBuildScript-}" ]; then
echo
echo "ERROR: no build script was specified"
echo 'Hint: set `npmBuildScript`, override `buildPhase`, or set `dontNpmBuild = true`.'
echo
exit 1
fi
if ! npm run ${npmWorkspace+--workspace=$npmWorkspace} "$npmBuildScript" $npmBuildFlags "${npmBuildFlagsArray[@]}" $npmFlags "${npmFlagsArray[@]}"; then
echo
echo 'ERROR: `npm build` failed'
echo
echo "Here are a few things you can try, depending on the error:"
echo "1. Make sure your build script ($npmBuildScript) exists"
echo ' If there is none, set `dontNpmBuild = true`.'
echo '2. If the error being thrown is something similar to "error:0308010C:digital envelope routines::unsupported", add `NODE_OPTIONS = "--openssl-legacy-provider"` to your derivation'
echo " See https://github.com/webpack/webpack/issues/14532 for more information."
echo
exit 1
fi
runHook postBuild
echo "Finished npmBuildHook"
}
if [ -z "${dontNpmBuild-}" ] && [ -z "${buildPhase-}" ]; then
buildPhase=npmBuildHook
fi