From 30468e0bd7fb21ea2e55672485bba2bf36a6f233 Mon Sep 17 00:00:00 2001
From: Kubat <mael.martin31@gmail.com>
Date: Tue, 3 Aug 2021 08:43:45 +0200
Subject: [PATCH] STPKG: Fix the edit ! (should be OK now)

Just in case: after an edit, the json in the exposed picker is not
updated, you may need to stpkg del && stpkg add it to take into account
the modifications.
---
 stpkg | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/stpkg b/stpkg
index 451d115..cc75fc7 100755
--- a/stpkg
+++ b/stpkg
@@ -576,11 +576,11 @@ __edit() {
     [ -z "$PACK_NAME" -o -z "$ACTION" -o -z "$STICKER_NAME" ] && die "Command argument are invalid, check the usage"
     shift 3
 
-    local FILE="${STPKG_INSTALL}web/packs/$PACK_NAME.json"
-    [ ! -r "$FILE" ] && die "Can't read file '$FILE' associated to the '$PACK_NAME' pack"
+    local JSON_FILE="${STPKG_INSTALL}web/packs/$PACK_NAME.json"
+    [ ! -r "$JSON_FILE" ] && die "Can't read file '$JSON_FILE' associated to the '$PACK_NAME' pack"
 
     local TEMP=`mktemp --suffix=.stpkg`
-    cp $FILE $TEMP
+    cp $JSON_FILE $TEMP
 
     case "$ACTION" in
         add)
@@ -618,8 +618,10 @@ __edit() {
 
     # TODO [OPTIONAL] Update the preview
     # TODO Add a dry mode, to only preview the change
+    # TODO If the pack was already added to the picker, re-add it to take into
+    #      account the modifications
     #jq < $TEMP ### to test/review the change
-    cp $TEMP $FILE
+    cp $TEMP $JSON_FILE
 }
 
 __add() {
-- 
GitLab