- 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)
34 lines
1.3 KiB
JavaScript
34 lines
1.3 KiB
JavaScript
#!/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);
|