Skip to content

Commit 350b16f

Browse files
committed
fix: prefer apt-fast or apt over apt-get
1 parent 4c0bf0a commit 350b16f

File tree

28 files changed

+56
-51
lines changed

28 files changed

+56
-51
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.3",
3+
"version": "3.1.0",
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/get-apt.ts

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,41 @@ export function hasNala() {
77
return which.sync("nala", { nothrow: true }) !== null
88
}
99

10+
/**
11+
* Check if apt-fast is installed
12+
*/
13+
export function hasAptFast() {
14+
return which.sync("apt-fast", { nothrow: true }) !== null
15+
}
16+
17+
/**
18+
* Check if apt is installed
19+
*/
20+
export function hasApt() {
21+
return which.sync("apt", { nothrow: true }) !== null
22+
}
23+
24+
/**
25+
* Check if apt-get is installed
26+
*/
27+
export function hasAptGet() {
28+
return which.sync("apt-get", { nothrow: true }) !== null
29+
}
30+
1031
/**
1132
* Get the apt command to use
1233
* If nala is installed, use that, otherwise use apt-get
1334
*/
1435
export function getApt() {
15-
let apt: string
1636
if (hasNala()) {
17-
apt = "nala"
37+
return "nala"
38+
} else if (hasAptFast()) {
39+
return "apt-fast"
40+
} else if (hasApt()) {
41+
return "apt"
42+
} else if (hasAptGet()) {
43+
return "apt-get"
1844
} else {
19-
apt = "apt-get"
45+
throw new Error("No apt command found")
2046
}
21-
return apt
2247
}

src/apt-fast/apt-fast.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ import { execRootSync } from "admina"
44
import { error } from "ci-log"
55
import { readFile, writeFile } from "fs/promises"
66
import { DownloaderHelper } from "node-downloader-helper"
7-
import { installAptPack } from "setup-apt"
7+
import { hasAptGet, installAptPack } from "setup-apt"
88
import which from "which"
9-
import { hasAptGet } from "../utils/env/hasAptGet.js"
109

1110
let binDir: string | undefined
1211

src/bazel/bazel.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import { execRoot } from "admina"
22
import { hasApk, installApkPack } from "setup-alpine"
3-
import { addAptKeyViaURL, installAptPack } from "setup-apt"
3+
import { addAptKeyViaURL, hasAptGet, installAptPack } from "setup-apt"
44
import { installBrewPack } from "setup-brew"
55
import { getDebArch } from "../utils/env/arch.js"
6-
import { hasAptGet } from "../utils/env/hasAptGet.js"
76
import { hasDnf } from "../utils/env/hasDnf.js"
87
import { isArch } from "../utils/env/isArch.js"
98
import { setupChocoPack } from "../utils/setup/setupChocoPack.js"

src/ccache/ccache.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { hasApk, installApkPack } from "setup-alpine"
2-
import { installAptPack } from "setup-apt"
2+
import { hasAptGet, installAptPack } from "setup-apt"
33
import { installBrewPack } from "setup-brew"
4-
import { hasAptGet } from "../utils/env/hasAptGet.js"
54
import { hasDnf } from "../utils/env/hasDnf.js"
65
import { isArch } from "../utils/env/isArch.js"
76
import { setupChocoPack } from "../utils/setup/setupChocoPack.js"

src/cppcheck/cppcheck.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import { addPath } from "envosman"
22
import { hasApk, installApkPack } from "setup-alpine"
3-
import { installAptPack } from "setup-apt"
3+
import { hasAptGet, installAptPack } from "setup-apt"
44
import { installBrewPack } from "setup-brew"
55
import { rcOptions } from "../options.js"
6-
import { hasAptGet } from "../utils/env/hasAptGet.js"
76
import { hasDnf } from "../utils/env/hasDnf.js"
87
import { isArch } from "../utils/env/isArch.js"
98
import { setupChocoPack } from "../utils/setup/setupChocoPack.js"

0 commit comments

Comments
 (0)