fix: settings-hook remove exits 1 when nothing to remove

gstack-settings-hook remove was exiting 0 when settings.json didn't
exist, causing gstack-uninstall to report "SessionStart hook" as
removed on clean systems where nothing was installed.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Garry Tan
2026-04-15 00:36:07 -07:00
parent 8a27649467
commit a35ae74475
2 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -54,7 +54,7 @@ case "$ACTION" in
" 2>/dev/null
;;
remove)
[ -f "$SETTINGS_FILE" ] || exit 0
[ -f "$SETTINGS_FILE" ] || exit 1
GSTACK_SETTINGS_PATH="$SETTINGS_FILE" bun -e "
const fs = require('fs');
const settingsPath = process.env.GSTACK_SETTINGS_PATH;
+2 -2
View File
@@ -85,11 +85,11 @@ describe('gstack-settings-hook', () => {
expect(settings.hooks).toBeUndefined();
});
test('remove is safe when settings.json does not exist', () => {
test('remove exits 1 when settings.json does not exist', () => {
const result = run(`${SETTINGS_HOOK} remove /path/to/gstack-session-update`, {
env: { GSTACK_SETTINGS_FILE: settingsFile },
});
expect(result.exitCode).toBe(0);
expect(result.exitCode).toBe(1);
});
test('remove preserves other hooks', () => {