1 # shellcheck shell=bash
3 nodejsInstallExecutables
() {
4 local -r packageJson
="${1-./package.json}"
6 local -r packageOut
="$out/lib/node_modules/$(@jq@ --raw-output '.name' package.json)"
8 # Based on code from Python's buildPythonPackage wrap.sh script, for
9 # supporting both the case when makeWrapperArgs is an array and a
10 # IFS-separated string.
12 # TODO: remove the string branch when __structuredAttrs are used.
13 if [[ "${makeWrapperArgs+defined}" == "defined" && "$(declare -p makeWrapperArgs)" =~ ^
'declare -a makeWrapperArgs=' ]]; then
14 local -a user_args
=("${makeWrapperArgs[@]}")
16 local -a user_args
="(${makeWrapperArgs:-})"
19 while IFS
=" " read -ra bin
; do
21 makeWrapper @hostNode@
"$out/bin/${bin[0]}" --add-flags "$packageOut/${bin[1]}" "${user_args[@]}"
22 done < <(@jq@
--raw-output '(.bin | type) as $typ | if $typ == "string" then
24 elif $typ == "object" then .bin | to_entries | map(.key + " " + .value) | join("\n")
25 elif $typ == "null" then empty
26 else "invalid type " + $typ | halt_error end' "$packageJson")