fix: escape the variant name in regex

This commit is contained in:
Amin Yahyaabadi 2025-02-27 12:18:03 -08:00
parent f3bd8fd76e
commit 4c635e726f
5 changed files with 6 additions and 5 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -4,6 +4,7 @@ import ciInfo from "ci-info"
const { GITHUB_ACTIONS } = ciInfo
import { error, warning } from "ci-log"
import { addEnv } from "envosman"
import escapeRegex from "escape-string-regexp"
import { execa } from "execa"
import { readdir } from "fs/promises"
import { pathExists } from "path-exists"
@ -200,7 +201,7 @@ async function findGccExe(variant: "gcc" | "g++", binDir: string, binVersion: st
}
// try to find the gcc exe in the bin dir
const gccExeRegex = new RegExp(`^${variant}-?(.*)(\\.exe)?$`)
const gccExeRegex = new RegExp(`^${escapeRegex(variant)}-?(.*)(\\.exe)?$`)
const files = (await readdir(binDir))
.filter((file) => gccExeRegex.test(file))
.sort(