mirror of
https://github.com/oven-sh/setup-bun.git
synced 2025-07-18 04:28:28 +02:00
fix: return output if found version
This commit is contained in:
parent
97de633240
commit
ff32c47b98
1 changed files with 8 additions and 3 deletions
11
src/utils.ts
11
src/utils.ts
|
@ -35,8 +35,7 @@ export function readVersionFromFile(
|
|||
|
||||
if (!files) {
|
||||
warning("No version file specified, trying all known files.");
|
||||
readVersionFromFile(Object.keys(FILE_VERSION_READERS));
|
||||
return;
|
||||
return readVersionFromFile(Object.keys(FILE_VERSION_READERS));
|
||||
}
|
||||
|
||||
if (!Array.isArray(files)) files = [files];
|
||||
|
@ -54,11 +53,17 @@ export function readVersionFromFile(
|
|||
|
||||
const reader = FILE_VERSION_READERS[base] ?? (() => undefined);
|
||||
|
||||
let output: string | undefined;
|
||||
try {
|
||||
return reader(readFileSync(path, "utf8"));
|
||||
output = reader(readFileSync(path, "utf8"));
|
||||
} catch (error) {
|
||||
const { message } = error as Error;
|
||||
warning(`Failed to read ${file}: ${message}`);
|
||||
} finally {
|
||||
if (output) {
|
||||
debug(`Found version ${output}`);
|
||||
return output;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue