Skip to content

Commit 660206b

Browse files
committed
fix: fix falling back to latest for apt
1 parent b59e0ce commit 660206b

File tree

6 files changed

+15
-18
lines changed

6 files changed

+15
-18
lines changed

dist/legacy/setup-cpp.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/legacy/setup-cpp.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/modern/setup-cpp.mjs

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

dist/modern/setup-cpp.mjs.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/setup-apt/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "setup-apt",
3-
"version": "3.0.1",
3+
"version": "3.0.2",
44
"description": "Setup apt packages and repositories in Debian/Ubuntu-based distributions",
55
"repository": "https://github.com/aminya/setup-cpp",
66
"homepage": "https://github.com/aminya/setup-cpp/tree/master/packages/setup-apt",

packages/setup-apt/src/qualify-install.ts

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { warning } from "ci-log"
21
import escapeRegex from "escape-string-regexp"
32
import { execa } from "execa"
43
import { getAptEnv } from "./apt-env.js"
@@ -37,7 +36,12 @@ export async function qualifiedNeededAptPackage(pack: AptPackage, apt: string =
3736
return (await isAptPackInstalled(qualified)) ? undefined : qualified
3837
}
3938

40-
async function aptPackageType(apt: string, name: string, version: string | undefined): Promise<AptPackageType> {
39+
async function aptPackageType(
40+
apt: string,
41+
name: string,
42+
version: string | undefined,
43+
fallBackToLatest: boolean,
44+
): Promise<AptPackageType> {
4145
if (version !== undefined && version !== "") {
4246
const { stdout } = await execa("apt-cache", [
4347
"search",
@@ -72,10 +76,10 @@ async function aptPackageType(apt: string, name: string, version: string | undef
7276
// If apt-cache fails, update the repos and try again
7377
if (!updatedRepos) {
7478
updateAptReposMemoized(apt)
75-
return aptPackageType(apt, name, version)
79+
return aptPackageType(apt, name, version, fallBackToLatest)
7680
}
7781

78-
if (version === undefined || version === "") {
82+
if (version === undefined || version === "" || fallBackToLatest) {
7983
// if the version is undefined or empty, return the name as a package name
8084
return AptPackageType.Name
8185
}
@@ -86,21 +90,14 @@ async function aptPackageType(apt: string, name: string, version: string | undef
8690
async function getAptArg(apt: string, pack: AptPackage) {
8791
const { name, version, fallBackToLatest = false } = pack
8892

89-
const package_type = await aptPackageType(apt, name, version)
93+
const package_type = await aptPackageType(apt, name, version, fallBackToLatest)
9094
switch (package_type) {
9195
case AptPackageType.NameDashVersion:
9296
return `${name}-${version}`
9397
case AptPackageType.NameEqualsVersion:
9498
return `${name}=${version}`
9599
case AptPackageType.Name: {
96-
if (version === undefined || version === "") {
97-
return name
98-
}
99-
if (fallBackToLatest) {
100-
warning(`Could not find package '${name}' with version '${version}'. Installing the latest version.`)
101-
return name
102-
}
103-
throw new Error(`Could not find package '${name}' with version '${version}'`)
100+
return name
104101
}
105102
default:
106103
throw new Error(`Could not find package '${name}' ${version ?? "with unspecified version"}`)

0 commit comments

Comments
 (0)