From b51958a3705a8ed3266153ec7c57e9fd1720c88c Mon Sep 17 00:00:00 2001 From: Compl Yue Date: Mon, 24 May 2021 00:37:41 +0800 Subject: [PATCH] populate `node_modules` from `host.js` in packages --- epm | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/epm b/epm index 22fb793..23b55bf 100755 --- a/epm +++ b/epm @@ -10,7 +10,7 @@ function main() { # @VARIABLE: VERSION # @DESCRIPTION: # Version of this script. - VERSION=0.2.11 + VERSION=0.3.0 # Default base URL for short package names BASE_URL=${EPM_REPO_BASE:-"https://github.com/e-wrks"} @@ -32,6 +32,7 @@ function main() { [ -w "${EPM_HOME}/edh_modules" ] || edo mkdir "${EPM_HOME}/edh_modules" [ -w "${EPM_HOME}/edh-universe/bin" ] || edo mkdir -p "${EPM_HOME}/edh-universe/bin" [ -w "${EPM_HOME}/python_modules" ] || edo mkdir "${EPM_HOME}/python_modules" + [ -w "${EPM_HOME}/node_modules" ] || edo mkdir "${EPM_HOME}/node_modules" ) || die "Can NOT create EPM home artifacts in [${EPM_HOME}]" } @@ -501,6 +502,18 @@ FLAGS: edo popd >/dev/null ) || die "Failed linking Python module artifacts" + ( + edo pushd node_modules >/dev/null + for a in ../"${pkg_dir}"/host.js/*; do + # deal with empty dir without nullglob + [ ! -e "$a" ] && continue + b=$(basename "$a") + edo rm -rf "./$b" 2>/dev/null + edo ln -s "$a" "$b" + done + edo popd >/dev/null + ) || die "Failed linking NodeJS module artifacts" + status_message "Installed $1 ." unset full_url pkg_id pkg_dir a b @@ -702,6 +715,25 @@ FLAGS: edo popd >/dev/null ) || die "Failed re-linking Python module artifacts" + ( + find node_modules -type l | while read -r modu_root; do + mr_path=$(readlink "${modu_root}") + if [ "${mr_path#../${pkg_dir1}/}" != "${mr_path}" ]; then + edo rm "${modu_root}" || die "Failed unlink ${modu_root}" + fi + done + + edo pushd node_modules >/dev/null + for a in ../"${pkg_dir}"/host.js/*; do + # deal with empty dir without nullglob + [ ! -e "$a" ] && continue + b=$(basename "$a") + edo rm -rf "./$b" 2>/dev/null + edo ln -s "$a" "$b" + done + edo popd >/dev/null + ) || die "Failed re-linking NodeJS module artifacts" + done ); } @@ -742,6 +774,12 @@ FLAGS: edo rm "${modu_root}" || die "Failed unlink ${modu_root}" fi done + find node_modules -type l | while read -r modu_root; do + mr_path=$(readlink "${modu_root}") + if [ "${mr_path#../${pkg_dir1}/}" != "${mr_path}" ]; then + edo rm "${modu_root}" || die "Failed unlink ${modu_root}" + fi + done edo rm -rf "${pkg_dir}" fi fi