18 lines
528 B
TypeScript
18 lines
528 B
TypeScript
import { AppVersions } from "../types";
|
|
|
|
export default function grabAppVersion(): (typeof AppVersions)[number] {
|
|
const appVersionEnv = process.env.NEXT_PUBLIC_VERSION;
|
|
const finalAppVersion = (appVersionEnv ||
|
|
"community") as (typeof AppVersions)[number]["value"];
|
|
|
|
const targetAppVersion = AppVersions.find(
|
|
(version) => version.value === finalAppVersion
|
|
);
|
|
|
|
if (!targetAppVersion) {
|
|
throw new Error(`Invalid App Version: ${finalAppVersion}`);
|
|
}
|
|
|
|
return targetAppVersion;
|
|
}
|