From aeef0bfeb5402070509649c17b24fefcfd38fea5 Mon Sep 17 00:00:00 2001 From: w4tchdoge Date: Mon, 23 Feb 2026 20:46:53 +0800 Subject: [PATCH] cheat: Prevent overwriting existing config (#7647) --- bucket/cheat.json | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bucket/cheat.json b/bucket/cheat.json index e930d911ee..347777a84b 100644 --- a/bucket/cheat.json +++ b/bucket/cheat.json @@ -23,9 +23,12 @@ "}" ], "post_install": [ + "# For the cheatsheets path to be set correctly, the configuration file should be initialized after the environment variables are set.", "$file = 'conf.yml'", - "$CONT = $(& \"$dir\\cheat\" --init) -replace 'editor: EDITOR_PATH', 'editor: notepad' -replace 'pager: PAGER_PATH', 'pager: more'", - "Set-Content \"$dir\\$file\" $CONT -Encoding ASCII" + "if ((Get-Item \"$dir\\$file\").Length -eq 0) {", + " $CONT = $(& \"$dir\\cheat\" --init) -replace 'editor: EDITOR_PATH', 'editor: notepad' -replace 'pager: PAGER_PATH', 'pager: more'", + " Set-Content \"$dir\\$file\" $CONT -Encoding ASCII", + "}" ], "env_set": { "CHEAT_CONFIG_PATH": "$dir\\conf.yml"