mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-10-04 08:22:30 +00:00
Fixed(cli):
- `ls` and `mirror` commands now provide informative feedback when no documents are found or filters skip all files, resolving the issue where they would exit silently (#860). - The command-line argument `vault` has been renamed to a more appropriate name, `databaseDir`. - The `mirror` command now accepts a `vault` directory, which specifies the location where the actual files are stored. For compatibility reasons, the previous behaviour is still supported. Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
Executable
+49
@@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
|
||||
CLI_DIR="$(cd -- "$SCRIPT_DIR/.." && pwd)"
|
||||
cd "$CLI_DIR"
|
||||
source "$SCRIPT_DIR/test-helpers.sh"
|
||||
|
||||
display_test_info "Test for Issue #860: Empty output from ls and mirror"
|
||||
|
||||
RUN_BUILD="${RUN_BUILD:-1}"
|
||||
cli_test_init_cli_cmd
|
||||
|
||||
WORK_DIR="$(mktemp -d "${TMPDIR:-/tmp}/livesync-repro-860.XXXXXX")"
|
||||
trap 'rm -rf "$WORK_DIR"' EXIT
|
||||
|
||||
SETTINGS_FILE="$WORK_DIR/data.json"
|
||||
VAULT_DIR="$WORK_DIR/vault"
|
||||
mkdir -p "$VAULT_DIR"
|
||||
|
||||
if [[ "$RUN_BUILD" == "1" ]]; then
|
||||
echo "[INFO] building CLI..."
|
||||
npm run build
|
||||
fi
|
||||
|
||||
echo "[INFO] generating settings -> $SETTINGS_FILE"
|
||||
cli_test_init_settings_file "$SETTINGS_FILE"
|
||||
|
||||
# 1. Test 'ls' on empty database
|
||||
echo "[INFO] Testing 'ls' on empty database..."
|
||||
LS_OUTPUT=$(run_cli "$VAULT_DIR" --settings "$SETTINGS_FILE" ls)
|
||||
if [[ -z "$LS_OUTPUT" ]]; then
|
||||
echo "[REPRODUCED] 'ls' returned empty output for empty database."
|
||||
else
|
||||
echo "[INFO] 'ls' output: $LS_OUTPUT"
|
||||
fi
|
||||
|
||||
# 2. Test 'mirror' on empty vault
|
||||
echo "[INFO] Testing 'mirror' on empty vault..."
|
||||
MIRROR_OUTPUT=$(run_cli "$VAULT_DIR" --settings "$SETTINGS_FILE" mirror 2>&1)
|
||||
if [[ "$MIRROR_OUTPUT" == *"[Command] mirror"* ]] && [[ ! "$MIRROR_OUTPUT" == *"[Mirror]"* ]]; then
|
||||
# Note: currently it prints [Command] mirror to stderr.
|
||||
# Let's see if it prints anything else.
|
||||
echo "[REPRODUCED] 'mirror' produced no functional logs (only command header)."
|
||||
else
|
||||
echo "[INFO] 'mirror' output: $MIRROR_OUTPUT"
|
||||
fi
|
||||
|
||||
echo "[DONE] finished repro-860 test"
|
||||
Reference in New Issue
Block a user