fix: escape regex of the name-version apt package

This commit is contained in:
Amin Yahyaabadi 2022-11-22 21:51:51 -08:00
parent dac72316df
commit 5505d67258
7 changed files with 14 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

@ -59,6 +59,7 @@
"ci-log": "workspace:1.0.0",
"escape-path-with-spaces": "github:aminya/escape-path-with-spaces#d9f81ee649203ddc55783a2f96ada59df06118e3",
"escape-quotes": "^1.0.2",
"escape-string-regexp": "^5.0.0",
"exec-powershell": "workspace:1.0.0",
"execa": "^5.1.1",
"is-url-online": "^1.5.0",

View File

@ -31,6 +31,7 @@ importers:
cspell: ^6.14.3
escape-path-with-spaces: github:aminya/escape-path-with-spaces#d9f81ee649203ddc55783a2f96ada59df06118e3
escape-quotes: ^1.0.2
escape-string-regexp: ^5.0.0
eslint: ^8.28.0
eslint-config-atomic: ^1.18.1
exec-powershell: workspace:1.0.0
@ -73,6 +74,7 @@ importers:
ci-log: link:packages/ci-log
escape-path-with-spaces: github.com/aminya/escape-path-with-spaces/d9f81ee649203ddc55783a2f96ada59df06118e3
escape-quotes: 1.0.2
escape-string-regexp: 5.0.0
exec-powershell: link:packages/exec-powershell
execa: 5.1.1
is-url-online: 1.5.0

View File

@ -9,6 +9,7 @@ import pathExists from "path-exists"
import { promises as fsPromises } from "fs"
const { appendFile } = fsPromises
import execa from "execa"
import escapeRegex from "escape-string-regexp"
let didUpdate: boolean = false
let didInit: boolean = false
@ -58,7 +59,12 @@ export async function setupAptPack(packages: AptPackage[], update = false): Prom
async function getAptArg(name: string, version: string | undefined) {
if (version !== undefined && version !== "") {
const { stdout } = await execa("apt-cache", ["search", "--names-only", `^${name}-${version}$`])
console.log(`^${escapeRegex(`${name}-${version}`)}$`)
const { stdout } = await execa("apt-cache", [
"search",
"--names-only",
`^${escapeRegex(name)}\-${escapeRegex(version)}$`,
])
if (stdout.trim() !== "") {
return `${name}-${version}`
} else {