Skip to content

Commit b09fe9d

Browse files
hotlongclaude
andcommitted
fix(scripts): route the new gate's entry guard through isEntrypoint (#16186)
`check:entry-guard` caught a hand-typed `process.argv[1]` comparison: it goes inert through a symlinked checkout, silently, at exit 0 — which for a gate means a green that never ran. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent 9d0fda8 commit b09fe9d

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

scripts/check-vendor-export-contract.mjs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ import { tmpdir } from 'node:os';
106106
import { dirname, join, resolve } from 'node:path';
107107
import { pathToFileURL, fileURLToPath } from 'node:url';
108108
import { workspacePackages } from './workspace-enumerator.mjs';
109+
import { isEntrypoint } from './invoked-as.mjs';
109110
import { EXIT_PREREQUISITE_NOT_MET, requireDefaultExport } from './import-prerequisite.mjs';
110111

111112
const semver = await requireDefaultExport('semver', () => import('semver'), import.meta.url);
@@ -548,11 +549,12 @@ function selfTest() {
548549

549550
// ── entry ──────────────────────────────────────────────────────────────────
550551

551-
// Only when RUN, never when imported: the self-test and the checklist tests
552-
// import the collector, and a module that runs its verdict on import would
553-
// make every importer inherit this gate's exit code.
554-
const isMain = process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url);
555-
const args = isMain ? process.argv.slice(2) : ['--noop'];
552+
// Only when RUN, never when imported: a caller that imports the collector must
553+
// not inherit this gate's exit code. `isEntrypoint` is the one predicate in
554+
// scripts/ that survives a symlinked checkout — a hand-typed process.argv[1]
555+
// comparison goes inert there, silently, at exit 0.
556+
const isMain = isEntrypoint(import.meta.url);
557+
const args = isMain ? process.argv.slice(2) : [];
556558
if (!isMain) {
557559
/* imported for its exports */
558560
} else if (args.includes('--self-test')) {

0 commit comments

Comments
 (0)