From 4b1efa2153bc73444aa6f45cfb0dd139ea27b12d Mon Sep 17 00:00:00 2001 From: mohit-Gaur75 Date: Tue, 24 Nov 2026 10:45:19 +0530 Subject: [PATCH] fix(scripts): support Windows paths and CRLF in protection and boundary scripts --- scripts/check-scoring-boundary.mjs | 3 ++- scripts/feed-github-protection.mjs | 1 + scripts/feed-github-protection.test.mjs | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/check-scoring-boundary.mjs b/scripts/check-scoring-boundary.mjs index 3691c2f9..d9e87927 100644 --- a/scripts/check-scoring-boundary.mjs +++ b/scripts/check-scoring-boundary.mjs @@ -17,8 +17,9 @@ import { execFileSync } from "node:child_process"; import { readFileSync, readdirSync, statSync } from "node:fs"; import { join, relative } from "node:path"; +import { fileURLToPath } from "node:url"; -const root = new URL("..", import.meta.url).pathname; +const root = fileURLToPath(new URL("..", import.meta.url)); const scoringDir = join(root, "scoring"); const errors = []; diff --git a/scripts/feed-github-protection.mjs b/scripts/feed-github-protection.mjs index d678f8cd..2324ccb4 100644 --- a/scripts/feed-github-protection.mjs +++ b/scripts/feed-github-protection.mjs @@ -74,6 +74,7 @@ export async function captureState(request = githubRequest) { } export function validatePRChecks(workflow = readFileSync(resolve(prWorkflowPath), 'utf8')) { + workflow = workflow.replace(/\r\n/g, '\n'); assert(/^ pull_request:\s*$/m.test(workflow), 'CI must run PR merge compatibility checks'); assert(!/^ pull_request:\s*\n (paths|paths-ignore|branches|branches-ignore):/m.test(workflow), 'Required PR checks must run for every pull request (no path or branch filters)'); const jobs = workflow.slice(workflow.indexOf('\njobs:\n')); diff --git a/scripts/feed-github-protection.test.mjs b/scripts/feed-github-protection.test.mjs index a91d85f2..60cf349a 100644 --- a/scripts/feed-github-protection.test.mjs +++ b/scripts/feed-github-protection.test.mjs @@ -3,7 +3,7 @@ import assert from 'node:assert/strict'; import { readFileSync } from 'node:fs'; import { applyPlan, buildPlan, captureState, environmentTargets, hash, owner, repository, requiredPRJobs, rulesetId, validatePRChecks, verifyExisting, verifyExistingState } from './feed-github-protection.mjs'; -const workflow = readFileSync('.github/workflows/scoring.yml', 'utf8'); +const workflow = readFileSync('.github/workflows/scoring.yml', 'utf8').replace(/\r\n/g, '\n'); const clone = value => JSON.parse(JSON.stringify(value)); function server() { const data = {