From ff32c47b98dc78948e1b7724ce217bc85a5a95e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jozef=20Steinh=C3=BCbl?= Date: Tue, 7 May 2024 20:31:34 +0200 Subject: [PATCH] fix: return output if found version --- src/utils.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index ab24c10..a23c1c7 100644 --- a/src/utils.ts +++ b/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; + } } } }