mirror of
https://github.com/tw93/Mole.git
synced 2026-02-04 11:31:46 +00:00
docs: add help text and test for 'mo update --force'
This commit is contained in:
1
mole
1
mole
@@ -223,6 +223,7 @@ show_help() {
|
||||
printf " %s%-28s%s %s\n" "$GREEN" "mo optimize --dry-run" "$NC" "Preview optimization"
|
||||
printf " %s%-28s%s %s\n" "$GREEN" "mo optimize --whitelist" "$NC" "Manage protected items"
|
||||
printf " %s%-28s%s %s\n" "$GREEN" "mo purge --paths" "$NC" "Configure scan directories"
|
||||
printf " %s%-28s%s %s\n" "$GREEN" "mo update --force" "$NC" "Force reinstall latest version"
|
||||
echo
|
||||
printf "%s%s%s\n" "$BLUE" "OPTIONS" "$NC"
|
||||
printf " %s%-28s%s %s\n" "$GREEN" "--debug" "$NC" "Show detailed operation logs"
|
||||
|
||||
@@ -392,3 +392,52 @@ EOF
|
||||
[[ "$output" == *"Updated to latest version (1.23.1)"* ]]
|
||||
[[ "$output" != *"progress: 100%"* ]] || [[ "$output" == *"Downloading (progress: 100%)"* ]]
|
||||
}
|
||||
|
||||
@test "update_mole with --force reinstalls even when on latest version" {
|
||||
run env HOME="$HOME" PROJECT_ROOT="$PROJECT_ROOT" CURRENT_VERSION="$CURRENT_VERSION" PATH="$HOME/fake-bin:/usr/bin:/bin" TERM="dumb" bash --noprofile --norc << 'EOF'
|
||||
set -euo pipefail
|
||||
curl() {
|
||||
local out=""
|
||||
local url=""
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
-o)
|
||||
out="$2"
|
||||
shift 2
|
||||
;;
|
||||
http*://*)
|
||||
url="$1"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ -n "$out" ]]; then
|
||||
cat > "$out" << 'INSTALLER'
|
||||
#!/usr/bin/env bash
|
||||
echo "Mole installed successfully (version $CURRENT_VERSION)"
|
||||
INSTALLER
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [[ "$url" == *"api.github.com"* ]]; then
|
||||
echo "{\"tag_name\":\"$CURRENT_VERSION\"}"
|
||||
else
|
||||
echo "VERSION=\"$CURRENT_VERSION\""
|
||||
fi
|
||||
}
|
||||
export -f curl
|
||||
|
||||
brew() { exit 1; }
|
||||
export -f brew
|
||||
|
||||
"$PROJECT_ROOT/mole" update --force
|
||||
EOF
|
||||
|
||||
[ "$status" -eq 0 ]
|
||||
[[ "$output" != *"Already on latest version"* ]]
|
||||
[[ "$output" == *"Downloading"* ]] || [[ "$output" == *"Installing"* ]] || [[ "$output" == *"Updated"* ]]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user