Skip to content

Commit e0accbf

Browse files
os-zhuangclaude
andcommitted
fix(ci): route pr-labels entry guard through invoked-as.mjs
check:entry-guard rejected the hand-typed `process.argv[1]` comparison the previous commit shipped. The gate is right: node resolves symlinks for the module graph but leaves `process.argv[1]` as the caller typed it, so the hand-typed guard answers false through a symlink and the script does nothing -- exit 0, no output, which a caller reading the status reads as success. Measured on this tree with the two spellings side by side, each reached directly and through a symlink: old-guard -> exit=0 output=RAN old-link -> exit=0 output=(nothing) new-guard -> exit=0 output=RAN new-link -> exit=0 output=RAN `scripts/**` has exactly one sanctioned predicate. Uses it, and drops the now unused pathToFileURL import. The file stays OFF KNOWN_IMPORT_UNSAFE: it exports bindings and the gate still counts 10 known-unsafe (unchanged), with this file among the 75 inert exporters. Verified directly -- importing it with `--size` in argv runs nothing and still yields every export. Refs #10703 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DdCnBGcHeufjrq7drTD3wt
1 parent ce525a0 commit e0accbf

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

scripts/pr-labels.mjs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@
107107
*/
108108

109109
import { readFileSync } from 'node:fs';
110-
import { fileURLToPath, pathToFileURL } from 'node:url';
110+
import { fileURLToPath } from 'node:url';
111+
import { isEntrypoint } from './invoked-as.mjs';
111112

112113
const REPO_ROOT = new URL('..', import.meta.url);
113114
const DEFAULT_LABELER_CONFIG = fileURLToPath(new URL('.github/labeler.yml', REPO_ROOT));
@@ -767,7 +768,14 @@ async function main() {
767768
// Only drive the CLI when this file IS the entry point. Importing it (the
768769
// self-test harness, or an ad-hoc check against a real PR's file list) must not
769770
// fire a mode off `process.argv` that belongs to the importer.
770-
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
771+
//
772+
// `isEntrypoint` is the ONE sanctioned predicate for this in `scripts/**`, and
773+
// hand-typing the comparison is what check:entry-guard exists to stop. Node
774+
// resolves symlinks for the module graph but leaves `process.argv[1]` as the
775+
// caller typed it, so a hand-typed guard answers `false` through a symlink and
776+
// the script then does NOTHING -- exit 0, no output, which a caller reading the
777+
// status reads as success.
778+
if (isEntrypoint(import.meta.url)) {
771779
main().catch((error) => {
772780
console.error(`pr-labels: ${error.message}`);
773781
process.exit(1);

0 commit comments

Comments
 (0)