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:
@@ -1,2 +1,3 @@
|
|||||||
export { resolveUnitTargetPath, writeUnitFiles } from './fs.ts';
|
export { resolveUnitTargetPath, writeUnitFiles } from './fs.ts';
|
||||||
export { deriveNameFromExec } from './misc.ts';
|
export { deriveNameFromExec } from './misc.ts';
|
||||||
|
export { getVersion } from './version.ts';
|
||||||
|
12
src/utils/version.ts
Normal file
12
src/utils/version.ts
Normal 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';
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user