fix(#4759): hooks marker warning states the will-not-load claim conditionally, like the plugin path (#4875)

* test(#4759): failing-first — preserved-foreign hooks warning must not claim may-not-load for a commonjs package.json

* fix(#4759): hooks marker warning states the will-not-load claim conditionally, like the plugin path

* test(#4759): review fold-ins — assert installer output on stdout+stderr (warn is stderr), register cleanup before the spawn, add the type-less foreign case

* chore(#4759): changeset fragment

* chore(#4759): backfill changeset PR number (4875)

---------

Co-authored-by: sim <sim@local>
This commit is contained in:
Tom Boucher
2026-09-19 10:55:01 -04:00
committed by GitHub
parent d36514b816
commit 969456c46d
3 changed files with 119 additions and 1 deletions

View File

@@ -12122,7 +12122,14 @@ function install(isGlobal, runtime = DEFAULT_RUNTIME, options = {}) {
console.log(` ${green}✓${reset} Wrote ${sharedHooksDirName}/package.json (CommonJS mode)`);
break;
case 'preserved-foreign':
console.warn(` ${yellow}⚠${reset} Left existing ${sharedHooksDirName}/package.json untouched (not GSD's marker) — GSD hooks may not resolve as CommonJS`);
// #4759: the foreign file usually DOES declare "type": "commonjs" —
// any hand-written or formatter-touched package.json does — and Node
// then loads the staged .js hooks as CommonJS, so the old
// unconditional "may not resolve" claim was usually false. The
// sibling plugin path (src/install-engine.cts) words this same
// outcome conditionally; match it and keep will-not-load conditional
// on "type": "module", the only case where it is true.
console.warn(` ${yellow}⚠${reset} Left existing ${sharedHooksDirName}/package.json untouched (not GSD's marker). If it declares "type": "module", the staged hooks will not load.`);
break;
case 'failed':
// Best-effort: a read-only or full config dir must not abort the