Files
msd-core/tests/helpers/exit-code-artifact-flags.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

41 lines
1.8 KiB
JavaScript

'use strict';
/**
* tests/helpers/exit-code-artifact-flags.cjs
*
* Shared flag-derivation seam for scripts/gen-exit-code-registry.cjs test
* callers. The generator emits FIVE artifacts (primary, scripts, hooks, dts,
* sh) driven by `--out`/`--scripts-out`/`--hooks-out`/`--dts-out`/`--sh-out`.
* Any call that supplies `--out` without also supplying matching overrides
* for the other four would, under `--write`, clobber the real committed
* `scripts/lib/exit-code-registry.cjs`, `hooks/lib/exit-code-registry.js`,
* `src/exit-code-registry.d.cts`, and `msd-core/bin/shared/exit-codes.sh` —
* dangerous since test files in this repo run in parallel.
*
* `ensureScriptsOut` derives co-located, per-call-unique secondary/hooks/
* dts/sh paths from whatever `--out` value the caller already supplies,
* whenever the caller has not already supplied its own override. Calls with
* no explicit `--out` (the "real committed set" checks) are left untouched.
*
* Extracted so every test file that drives this generator's five-artifact
* flag surface shares ONE derivation — CONTRIBUTING.md's ban on re-deriving
* a shared flag-builder applies here.
*/
/** @param {string[]} args
* @returns {string[]}
*/
function ensureScriptsOut(args) {
const outIdx = args.indexOf('--out');
if (outIdx === -1) return args;
const outValue = args[outIdx + 1];
const extra = [];
if (!args.includes('--scripts-out')) extra.push('--scripts-out', `${outValue}.secondary.cjs`);
if (!args.includes('--hooks-out')) extra.push('--hooks-out', `${outValue}.hooks.js`);
if (!args.includes('--dts-out')) extra.push('--dts-out', `${outValue}.d.cts`);
if (!args.includes('--sh-out')) extra.push('--sh-out', `${outValue}.sh`);
return extra.length === 0 ? args : [...args, ...extra];
}
module.exports = { ensureScriptsOut };