mirror of
https://github.com/YuJunZhiXue/dsh-purge.git
synced 2026-11-28 03:30:22 +08:00
fix: silenceMnemonGitFlash 回退路径改用 let,避免 const 重赋值抛错
This commit is contained in:
1 parent
dfe217f32b
commit
864e6b7a3b
1 file changed
+5
-12
+5
-12
@@ -261,26 +261,19 @@ export function silenceMnemonGitFlash(dshHome = findDshHome()) {
|
||||
if (hit === "missing") hit = "pattern_miss";
|
||||
continue;
|
||||
}
|
||||
const next = text.replace(
|
||||
let next = text.replace(
|
||||
/function resolveGitBranch\(cwd\) \{[\s\S]*?\n\}\n\/\/#endregion\n\/\/#region src\/memory-view\.ts/,
|
||||
`${replacement}\n//#endregion\n//#region src/memory-view.ts`,
|
||||
);
|
||||
if (next === text) {
|
||||
// Fallback: replace the function only (region comment may differ by mnemon build).
|
||||
const alt = text.replace(
|
||||
next = text.replace(
|
||||
/function resolveGitBranch\(cwd\) \{[\s\S]*?\n\}(?=\n\/\/#endregion)/,
|
||||
replacement,
|
||||
);
|
||||
if (alt === text) {
|
||||
hit = "pattern_miss";
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
fs.writeFileSync(fp, alt, "utf8");
|
||||
hit = "patched";
|
||||
} catch (e) {
|
||||
hit = `error:${e}`;
|
||||
}
|
||||
}
|
||||
if (next === text) {
|
||||
hit = "pattern_miss";
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
|
||||
Reference in new issue
Block a user