mirror of
https://github.com/garrytan/gstack.git
synced 2026-05-21 12:18:24 +08:00
merge: PR #220 - fix(update-check): --force now clears snooze
This commit is contained in:
@@ -20,9 +20,10 @@ SNOOZE_FILE="$STATE_DIR/update-snoozed"
|
|||||||
VERSION_FILE="$GSTACK_DIR/VERSION"
|
VERSION_FILE="$GSTACK_DIR/VERSION"
|
||||||
REMOTE_URL="${GSTACK_REMOTE_URL:-https://raw.githubusercontent.com/garrytan/gstack/main/VERSION}"
|
REMOTE_URL="${GSTACK_REMOTE_URL:-https://raw.githubusercontent.com/garrytan/gstack/main/VERSION}"
|
||||||
|
|
||||||
# ─── Force flag (busts cache for standalone /gstack-upgrade) ──
|
# ─── Force flag (busts cache + snooze for standalone /gstack-upgrade) ──
|
||||||
if [ "${1:-}" = "--force" ]; then
|
if [ "${1:-}" = "--force" ]; then
|
||||||
rm -f "$CACHE_FILE"
|
rm -f "$CACHE_FILE"
|
||||||
|
rm -f "$SNOOZE_FILE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# ─── Step 0: Check if updates are disabled ────────────────────
|
# ─── Step 0: Check if updates are disabled ────────────────────
|
||||||
|
|||||||
@@ -447,6 +447,24 @@ describe('gstack-update-check', () => {
|
|||||||
expect(cache).toContain('UP_TO_DATE');
|
expect(cache).toContain('UP_TO_DATE');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('--force clears snooze so user can upgrade after snoozing', () => {
|
||||||
|
writeFileSync(join(gstackDir, 'VERSION'), '0.3.3\n');
|
||||||
|
writeFileSync(join(gstackDir, 'REMOTE_VERSION'), '0.4.0\n');
|
||||||
|
writeSnooze('0.4.0', 1, nowEpoch() - 60); // snoozed 1 min ago (within 24h)
|
||||||
|
|
||||||
|
// Without --force: snoozed, silent
|
||||||
|
const snoozed = run();
|
||||||
|
expect(snoozed.exitCode).toBe(0);
|
||||||
|
expect(snoozed.stdout).toBe('');
|
||||||
|
|
||||||
|
// With --force: snooze cleared, outputs upgrade
|
||||||
|
const forced = run({}, ['--force']);
|
||||||
|
expect(forced.exitCode).toBe(0);
|
||||||
|
expect(forced.stdout).toBe('UPGRADE_AVAILABLE 0.3.3 0.4.0');
|
||||||
|
// Snooze file should be deleted
|
||||||
|
expect(existsSync(join(stateDir, 'update-snoozed'))).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
// ─── Split TTL tests ─────────────────────────────────────────
|
// ─── Split TTL tests ─────────────────────────────────────────
|
||||||
|
|
||||||
test('UP_TO_DATE cache expires after 60 min (not 720)', () => {
|
test('UP_TO_DATE cache expires after 60 min (not 720)', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user