Files
msd-core/tests/helpers/shadow-report-throws-preload.cjs
Jakub Zych a9a7a328e6 refactor: hard-fork GSD -> MSD (Make Software Done)
Mechanical rename produced by scripts/msd-rename.cjs: gsd/Gsd/GSD -> msd/Msd/MSD
across contents and paths, upstream package/repo coordinates -> @golem15/msd-core
and golem15com/msd-core. Deep links into upstream history, sibling upstream
packages, the GSD-2 import feature, CHANGELOG.md and .changeset/ are kept as-is.

Hand edits on top: MSD block-letter banner and logos, LICENSE copyright line,
package/plugin identity, regenerated lockfile, install-tree fixtures, derived
registries and benchmark baseline; migration checksum baseline re-locked
(MSD keeps its own install state, so no install had applied the old sums);
sort-order and regex-escaped expectations in tests adjusted.
2026-10-06 01:47:40 +02:00

45 lines
2.1 KiB
JavaScript

'use strict';
/**
* Preload fixture for #2873 matrix row C5 — force the installer's
* cross-scope shadow-report call site (bin/install.js, immediately after
* writeManifest) to exercise its own swallow-everything catch.
*
* `install-shadow-report.cjs`'s `buildShadowReport()` only degrades a
* `TypeError` thrown by `resolveInstalledSurfaces` (returns
* `RESOLVER_UNAVAILABLE`); any OTHER error type it lets propagate — see its
* own doc comment. This preload replaces the exported `buildShadowReport`
* with a function that always throws a plain `Error`, so whatever calls it
* next (`bin/install.js`, requiring the SAME resolved module path and
* therefore getting the SAME cached module object) sees that throw and must
* swallow it without failing the install (design row C5: "a report failure
* never fails the install").
*
* Loaded via `node --require <this file> bin/install.js ...`
* (`tests/helpers/process-seam.cjs`'s `runNode` forwards extra argv
* verbatim, ahead of the target script) so the patch lands in the require
* cache BEFORE `bin/install.js`'s own
* `require('../msd-core/bin/lib/install-shadow-report.cjs')` resolves.
*
* One-shot subprocess: no restoration needed — the process exits right
* after the single `install()` call this preload targets. This is NOT a
* chmod/mode-bit trick (CONTRIBUTING.md: those no-op under root), and NOT
* the in-process fs fault-injection seam (`tests/helpers/faulty-deps.cjs`'s
* `withFaultyFs` is explicitly documented as in-process-only, since a
* spawned subprocess offers no shared memory to monkeypatch into) — this
* patches the ONE exported function the design doc names as the report
* builder, at the require-cache seam a spawned child process actually
* offers.
*/
const path = require('node:path');
const modPath = require.resolve(
path.join(__dirname, '..', '..', 'msd-core', 'bin', 'lib', 'install-shadow-report.cjs'),
);
const shadowReportModule = require(modPath);
shadowReportModule.buildShadowReport = function throwingBuildShadowReport() {
throw new Error('injected by tests/helpers/shadow-report-throws-preload.cjs (#2873 matrix row C5)');
};