mirror of
https://github.com/the-draupnir-project/Draupnir.git
synced 2026-10-22 17:11:17 +00:00
Use package.json version if version.txt is missing.
This commit is contained in:
1 parent
b7139b398c
commit
fea67c3821
1 file changed
+10
-10
+10
-10
@@ -285,9 +285,18 @@ export function getProvisionedMjolnirConfig(managementRoomId: string): IConfig {
|
||||
return config;
|
||||
}
|
||||
|
||||
export const PACKAGE_JSON = (() => {
|
||||
try {
|
||||
return JSON.parse(fs.readFileSync(path.join(__dirname, '../package.json'), 'utf-8'));
|
||||
} catch (e) {
|
||||
LogService.error("config", "Could not read Draupnir package.json", e);
|
||||
return {};
|
||||
}
|
||||
})();
|
||||
|
||||
export const SOFTWARE_VERSION = (() => {
|
||||
let versionFile;
|
||||
const defaultText = "A version was either not provided when building Draupnir or could not be read.";
|
||||
const defaultText = PACKAGE_JSON.version ?? "A version was either not provided when building Draupnir or could not be read.";
|
||||
try {
|
||||
versionFile = fs.readFileSync(path.join(__dirname, '../version.txt'), 'utf-8');
|
||||
} catch (e) {
|
||||
@@ -298,12 +307,3 @@ export const SOFTWARE_VERSION = (() => {
|
||||
// into <pre> or <code> where it will create an unnecessary newline.
|
||||
return /^(.*)$/m.exec(versionFile)?.at(0) ?? defaultText;
|
||||
})();
|
||||
|
||||
export const PACKAGE_JSON = (() => {
|
||||
try {
|
||||
return JSON.parse(fs.readFileSync(path.join(__dirname, '../package.json'), 'utf-8'));
|
||||
} catch (e) {
|
||||
LogService.error("config", "Could not read Draupnir package.json", e);
|
||||
return {};
|
||||
}
|
||||
})();
|
||||
Reference in new issue
Block a user