feat(utils): add version retrieval utility

- Introduces a function to retrieve the application version
- Returns 'dev' if the version file is missing and 'unknown' for other errors
- Exports the new utility for use in other modules
This commit is contained in:
2025-05-21 03:47:02 +02:00
parent 8ed98cc998
commit 56fb554f13
2 changed files with 13 additions and 0 deletions

View File

@@ -1,2 +1,3 @@
export { resolveUnitTargetPath, writeUnitFiles } from './fs.ts';
export { deriveNameFromExec } from './misc.ts';
export { getVersion } from './version.ts';

12
src/utils/version.ts Normal file
View File

@@ -0,0 +1,12 @@
export async function getVersion(): Promise<string> {
try {
const versionUrl = new URL('../../VERSION', import.meta.url);
const version = await Deno.readTextFile(versionUrl);
return version.trim();
} catch (err) {
if (err instanceof Deno.errors.NotFound) {
return 'dev';
}
return 'unknown';
}
}