logo

overlay

My own overlay for experimentations, use with caution, no support is provided git clone https://hacktivis.me/git/overlay.git
commit: 67534d81af77b0ce5d0f066913bd0a43cd839b13
parent e84d6142ac50e4b188df7acc48b5a39f369b03d0
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Sat, 16 Sep 2023 08:23:18 +0200

nodejs.eclass: Handle .bin entry being a string

Diffstat:

Meclass/nodejs.eclass26++++++++++++++++++++------
1 file changed, 20 insertions(+), 6 deletions(-)

diff --git a/eclass/nodejs.eclass b/eclass/nodejs.eclass @@ -98,13 +98,27 @@ nodejs_src_install() { test -e index.js && nodejs_install_path index.js fi - if jq -e 'has("bin")' <package.json >/dev/null - then - jq -r '.bin | to_entries | .[] | .key + " " + .value' <package.json \ - | while read bin file; do + bin_type="$(jq -r '.bin | type' <package.json)" + case "${bin_type}" in + null) + ;; + object) + jq -r '.bin | to_entries | .[] | .key + " " + .value' <package.json \ + | while read bin file; do + nodejs_install_path "${file}" + fperms 755 "${NODEJS_SITELIB}${PN}/${file#./}" + dosym "${NODEJS_SITELIB}${PN}/${file#./}" "/usr/bin/${bin}" + done + ;; + string) + file="$(jq -r '.bin' <package.json)" + bin="$(basename "${file}")" nodejs_install_path "${file}" fperms 755 "${NODEJS_SITELIB}${PN}/${file#./}" dosym "${NODEJS_SITELIB}${PN}/${file#./}" "/usr/bin/${bin}" - done - fi + ;; + *) + die "Unhandled package.json#bin type: ${bin_type}" + ;; + esac }