bookworm-smart-assistant/scripts/patches/patch-x06-processline-continue.js
Bookworm Admin b7a8e29d21 release: v6.7.0 - OTA E2E test release
- VERSION file as authoritative version source
- export.mjs reads VERSION with package.json fallback
- bw-ota.ps1 DryRun mode for safe testing
- auto-setup.ps1 bumped to v3.2.0 (Phase 8 OTA)
2026-04-27 17:59:44 +08:00

34 lines
1.3 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env node
// patch-x06: processLine() 中 return 应为 continue小 part 跳过导致同行大 part 丢失
'use strict';
const fs = require('fs');
const path = require('path');
const SENTINEL = '// [PATCH-X06-CONTINUE]';
const target = path.join(__dirname, '..', '..', 'hooks', 'pre-compact-handoff.js');
if (!fs.existsSync(target)) { process.stdout.write('[SKIP] not found\n'); process.exit(0); }
let raw = fs.readFileSync(target, 'utf8');
if (raw.includes(SENTINEL)) { process.stdout.write('[SKIP] already applied\n'); process.exit(0); }
const useCRLF = raw.includes('\r\n');
let content = useCRLF ? raw.replace(/\r\n/g, '\n') : raw;
const bak = target + '.bak.x06';
if (!fs.existsSync(bak)) fs.writeFileSync(bak, raw);
const OLD = ' if (size < 500) return;';
const NEW = ` if (size < 500) continue; ${SENTINEL}`;
if (!content.includes(OLD)) {
process.stdout.write('[ERROR] old pattern not found\n'); process.exit(1);
}
content = content.replace(OLD, NEW);
const final = useCRLF ? content.replace(/\n/g, '\r\n') : content;
fs.writeFileSync(target, final, 'utf8');
const v = fs.readFileSync(target, 'utf8');
process.stdout.write(v.includes(SENTINEL) ? '[DONE] patch-x06 applied\n' : '[ERROR] verify failed\n');
process.exit(v.includes(SENTINEL) ? 0 : 1);