Skip to content

Commit e1153da

Browse files
committed
fix(scripts): guard check-audit-scope against running on import
1 parent 46f58be commit e1153da

2 files changed

Lines changed: 14 additions & 11 deletions

File tree

scripts/check-entry-guard.mjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,6 @@ const KNOWN_IMPORT_UNSAFE = new Set([
441441
'scripts/check-query-options-erasure-ratchet.mjs',
442442
'scripts/check-release-page-status.mjs',
443443
'scripts/checklist-select.mjs',
444-
'scripts/docs-audit/check-audit-scope.mjs',
445444
'scripts/objectui-range.mjs',
446445
'scripts/pm/check-governed-prose.mjs',
447446
'scripts/qa/qa-rollup.mjs',

scripts/docs-audit/check-audit-scope.mjs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ import { readFileSync, writeFileSync } from 'node:fs';
8787
import { join, dirname } from 'node:path';
8888
import { fileURLToPath } from 'node:url';
8989
import { createContext, runInContext } from 'node:vm';
90+
import { isEntrypoint } from '../invoked-as.mjs';
9091

9192
const HERE = dirname(fileURLToPath(import.meta.url));
9293
const REPO_ROOT = execFileSync('git', ['rev-parse', '--show-toplevel'], { cwd: HERE })
@@ -466,17 +467,20 @@ export async function checkReadOnlyRouting(source) {
466467

467468
// --- main --------------------------------------------------------------------
468469

469-
try {
470-
if (args.includes('--self-test')) {
471-
await selfTest();
472-
process.exit(0);
470+
// Exports bindings, so an import for those exports alone must run nothing (#10667).
471+
if (isEntrypoint(import.meta.url)) {
472+
try {
473+
if (args.includes('--self-test')) {
474+
await selfTest();
475+
process.exit(0);
476+
}
477+
await main();
478+
} catch (e) {
479+
// A structural failure (markers gone, list unparseable, derivation empty) is
480+
// a RED result with a readable reason — never a stack trace, never a pass.
481+
console.error(`✗ ${e.message}`);
482+
process.exit(1);
473483
}
474-
await main();
475-
} catch (e) {
476-
// A structural failure (markers gone, list unparseable, derivation empty) is a
477-
// RED result with a readable reason — never a stack trace, and never a pass.
478-
console.error(`✗ ${e.message}`);
479-
process.exit(1);
480484
}
481485

482486
async function main() {

0 commit comments

Comments
 (0)