Skip to content

Commit 1d824aa

Browse files
committed
fix: install the setup-cpp cli in all envs
1 parent 4f0c49a commit 1d824aa

File tree

7 files changed

+22
-12
lines changed

7 files changed

+22
-12
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.

src/cli-options.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ import { type Inputs, inputs } from "./tool.js"
66
import type { InstallationInfo } from "./utils/setup/setupBin.js"
77

88
export function parseArgs(args: string[]): Opts {
9-
return mri<Record<Inputs, string | undefined> & { help: boolean }>(args, {
9+
return mri<Record<Inputs, string | undefined> & { help: boolean; version: boolean }>(args, {
1010
string: [...inputs, "timeout", "nodePackageManager"],
1111
default: Object.fromEntries(inputs.map((inp) => [inp, maybeGetInput(inp)])),
12-
alias: { h: "help" },
13-
boolean: "help",
12+
alias: { h: "help", v: "version" },
13+
boolean: ["help", "version"],
1414
})
1515
}
1616

@@ -25,8 +25,10 @@ Install all the tools required for building and testing C++/C projects.
2525
--timeout\t the timeout for the installation of each tool in minutes. By default it is 10 minutes.
2626
--compiler\t the <compiler> to install.
2727
\t You can specify the version instead of specifying just the name e.g: --compiler 'llvm-13.0.0'
28-
--$tool_name\t pass "true" or pass the <version> you would like to install for this tool. e.g. --conan true or --conan "1.42.1"
28+
--tool_name\t pass "true" or pass the <version> you would like to install for this tool. e.g. --conan true or --conan "1.42.1"
2929
--nodePackageManager\t the node package manager to use (npm/yarn/pnpm) when installing setup-cpp globally
30+
--help\t show this help message
31+
--version\t show the version of setup-cpp
3032
3133
All the available tools:
3234
`)
@@ -64,6 +66,7 @@ export function maybeGetInput(key: string) {
6466
export type Opts = mri.Argv<
6567
Record<Inputs, string | undefined> & {
6668
help: boolean
69+
version: boolean
6770
timeout?: string
6871
nodePackageManager?: string
6972
}

src/setup-cpp-installer.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { GITHUB_ACTIONS } from "ci-info"
21
import { error, info } from "ci-log"
32
import { execa } from "execa"
43
/**
@@ -8,8 +7,9 @@ import { execa } from "execa"
87
*/
98
export async function installSetupCpp(version: string, packageManager: string = "npm") {
109
try {
11-
// check if running in github actions
12-
if (!GITHUB_ACTIONS) {
10+
// check if `setup-cpp` is available in the shell, if so, skip the installation to avoid overwriting the existing version
11+
const { stdout } = await execa("setup-cpp", ["--version"])
12+
if (stdout) {
1313
return
1414
}
1515

src/setup-cpp.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ async function main(args: string[]): Promise<number> {
3535
printHelp()
3636
}
3737

38+
// print version
39+
if (opts.version) {
40+
info(`${packageJson.version}`)
41+
}
42+
3843
// cpu architecture
3944
const arch = opts.architecture ?? process.arch
4045

@@ -123,7 +128,9 @@ async function main(args: string[]): Promise<number> {
123128
await finalizeRC(rcOptions)
124129

125130
if (successMessages.length === 0 && errorMessages.length === 0) {
126-
info("setup-cpp was called without any arguments. Nothing to do.")
131+
if (!opts.version && !opts.help) {
132+
info("setup-cpp was called without any arguments. Nothing to do.")
133+
}
127134
return 0
128135
}
129136

0 commit comments

Comments
 (0)