From 31d9ae87b7a7d0816ef6cc7b8f0ce1c28c0db89d Mon Sep 17 00:00:00 2001 From: fred Date: Thu, 25 Apr 2024 13:52:57 +0200 Subject: [PATCH] import_tiddler.sh "TWpath/index.html" "TIDpath/tiddler.json" --- RUNTIME/TW/import_tiddler.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/RUNTIME/TW/import_tiddler.sh b/RUNTIME/TW/import_tiddler.sh index 7ceca8b1..417d0509 100755 --- a/RUNTIME/TW/import_tiddler.sh +++ b/RUNTIME/TW/import_tiddler.sh @@ -5,14 +5,18 @@ MOATS=$(date -u +"%Y%m%d%H%M%S%4N") # Check if TiddlyWiki file exists TW="$1" -[[ ! -s $TW ]] && echo "No TiddlyWiki found at: $TW" && exit 1 +[[ ! -s $TW ]] \ + && echo "Missing TiddlyWiki index.html \$1: $TW" \ + && exit 1 # Check if Tiddler JSON file exists TIDDLER="$2" -[[ ! -s $TIDDLER || $TIDDLER == "" ]] && echo "Need a Tiddler JSON file" && exit 1 +[[ ! -s $TIDDLER || $TIDDLER == "" ]] \ + && echo "Missing Tiddler JSON file \$2: $TIDDLER" \ + && exit 1 # Add created and modified fields to the Tiddler JSON file -echo "Adding created and modified fields to ${TIDDLER}..." +echo "Putting ${TIDDLER} in ${TW}" jq '.[] + {created: $MOATS, modified: $MOATS}' --arg MOATS "$MOATS" "$TIDDLER" > "${TIDDLER}.tmp" # Run TiddlyWiki import command @@ -30,8 +34,8 @@ if [[ -s /tmp/${MOATS}.html ]]; then rm "${TIDDLER}.tmp" echo "Updated TiddlyWiki: ${TW}" + exit 0 else + echo "ERROR" exit 1 fi - -echo "Done."