mirror of
https://github.com/getpaseo/paseo.git
synced 2026-07-29 12:01:31 +00:00
35 lines
754 B
TypeScript
35 lines
754 B
TypeScript
import Constants from "expo-constants";
|
|
import appPackage from "../../package.json";
|
|
|
|
function toVersionOrNull(value: unknown): string | null {
|
|
if (typeof value !== "string") {
|
|
return null;
|
|
}
|
|
|
|
const trimmed = value.trim();
|
|
if (trimmed.length === 0) {
|
|
return null;
|
|
}
|
|
|
|
return trimmed;
|
|
}
|
|
|
|
export function resolveAppVersion(): string | null {
|
|
const packageVersion = toVersionOrNull(appPackage?.version);
|
|
if (packageVersion) {
|
|
return packageVersion;
|
|
}
|
|
|
|
const expoVersion = toVersionOrNull(Constants.expoConfig?.version);
|
|
if (expoVersion) {
|
|
return expoVersion;
|
|
}
|
|
|
|
const manifestVersion = toVersionOrNull((Constants as any).manifest?.version);
|
|
if (manifestVersion) {
|
|
return manifestVersion;
|
|
}
|
|
|
|
return null;
|
|
}
|