From 28b147f1b32a3e063a09763c75a37348ec90bb90 Mon Sep 17 00:00:00 2001 From: Reuben Miller Date: Thu, 26 Oct 2023 17:46:57 +0200 Subject: [PATCH] fixup! fix: handle project names with spaces in their names --- src/sm-plugin/nodered | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/sm-plugin/nodered b/src/sm-plugin/nodered index 6307e96..cf0a61a 100755 --- a/src/sm-plugin/nodered +++ b/src/sm-plugin/nodered @@ -126,7 +126,8 @@ activate_project() { fi log "Activating the project: $name" - response=$(curl --silent -H "Content-Type: application/json" -XPUT "$(escape_url "$NODERED_API/projects/$name")" -d '{"active":true,"clearContext":true}') + escaped_name="$(escape_url "$name")" + response=$(curl --silent -H "Content-Type: application/json" -XPUT "$NODERED_API/projects/$escaped_name" -d '{"active":true,"clearContext":true}') if [ "$(echo "$response" | jq -r '.active')" = "$name" ]; then log "\nSuccessfully activated project. name=$name" @@ -285,10 +286,13 @@ case "$COMMAND" in # Use while loop and here string to support project names with spaces in their names while read -r PROJECT; do if [ "$PROJECT" = "$ACTIVE_PROJECT" ]; then - curl "$(escape_url "$NODERED_API/projects/$PROJECT")" --silent | jq -r '["active-project", .name], [.name, .version] | @tsv' + escaped_name="$(escape_url "$PROJECT")" + curl "$NODERED_API/projects/$escaped_name" --silent | jq -r '["active-project", .name], [.name, .version] | @tsv' else - # node-red only allows querying the active project. So we have to resort to checking the package.json - jq -r '[.name, .version] | @tsv' < "$NODERED_DIR/projects/$PROJECT/package.json" + if [ -f "$NODERED_DIR/projects/$PROJECT/package.json" ]; then + # node-red only allows querying the active project. So we have to resort to checking the package.json + jq -r '[.name, .version] | @tsv' < "$NODERED_DIR/projects/$PROJECT/package.json" + fi fi done <