patchcord 0.5.96 → 0.5.97
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/patchcord.mjs +13 -10
- package/package.json +1 -1
package/bin/patchcord.mjs
CHANGED
|
@@ -1225,16 +1225,19 @@ if (!cmd || cmd === "install" || cmd === "agent" || cmd?.startsWith("--")) {
|
|
|
1225
1225
|
copyFileSync(hookScriptSrc, hookScriptDest);
|
|
1226
1226
|
chmodSync(hookScriptDest, 0o755);
|
|
1227
1227
|
|
|
1228
|
-
// Enable hooks feature flag
|
|
1229
|
-
//
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
}
|
|
1236
|
-
|
|
1237
|
-
|
|
1228
|
+
// Enable the `hooks` feature flag exactly once. Older installs / Codex
|
|
1229
|
+
// versions may leave `codex_hooks = true`, `hooks=true` (no spaces), a
|
|
1230
|
+
// `hooks = false`, or even a duplicate `hooks = true` — any of which makes
|
|
1231
|
+
// config.toml fail to load with a "duplicate key" error. Strip every
|
|
1232
|
+
// feature-flag variant first, then add exactly one under [features].
|
|
1233
|
+
globalCodexContent = globalCodexContent
|
|
1234
|
+
.replace(/^[ \t]*(?:codex_)?hooks[ \t]*=[ \t]*(?:true|false)[ \t]*(?:#[^\n]*)?\r?\n?/gm, "")
|
|
1235
|
+
.replace(/\n{3,}/g, "\n\n")
|
|
1236
|
+
.trimEnd() + "\n";
|
|
1237
|
+
if (/^\[features\][ \t]*$/m.test(globalCodexContent)) {
|
|
1238
|
+
globalCodexContent = globalCodexContent.replace(/^(\[features\][ \t]*\r?\n)/m, "$1hooks = true\n");
|
|
1239
|
+
} else {
|
|
1240
|
+
globalCodexContent = globalCodexContent.trimEnd() + "\n\n[features]\nhooks = true\n";
|
|
1238
1241
|
}
|
|
1239
1242
|
|
|
1240
1243
|
// Remove any old patchcord stop hook entry from config.toml (moved to hooks.json)
|