mirror of
https://github.com/oven-sh/setup-bun.git
synced 2025-07-18 04:28:28 +02:00
feat: support .tool-versions (#68)
* feat: support .tool-versions * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
194c60efc3
commit
9e6479509b
3 changed files with 81 additions and 26 deletions
26
src/index.ts
26
src/index.ts
|
@ -36,8 +36,32 @@ function readVersionFromPackageJson(): string | undefined {
|
|||
}
|
||||
}
|
||||
|
||||
function readVersionFromToolVersions(): string | undefined {
|
||||
const cwd = process.env.GITHUB_WORKSPACE;
|
||||
if (!cwd) {
|
||||
return;
|
||||
}
|
||||
const path = join(cwd, ".tool-versions");
|
||||
try {
|
||||
if (!existsSync(path)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const match = readFileSync(path, "utf8").match(/^bun\s(?<version>.*?)$/m);
|
||||
|
||||
return match?.groups?.version;
|
||||
} catch (error) {
|
||||
const { message } = error as Error;
|
||||
warning(`Failed to read .tool-versions: ${message}`);
|
||||
}
|
||||
}
|
||||
|
||||
runAction({
|
||||
version: getInput("bun-version") || readVersionFromPackageJson() || undefined,
|
||||
version:
|
||||
getInput("bun-version") ||
|
||||
readVersionFromPackageJson() ||
|
||||
readVersionFromToolVersions() ||
|
||||
undefined,
|
||||
customUrl: getInput("bun-download-url") || undefined,
|
||||
registryUrl: getInput("registry-url") || undefined,
|
||||
scope: getInput("scope") || undefined,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue