fix: slice dep versions only if starts with ^

This commit is contained in:
Jozef Steinhübl 2024-04-13 21:15:43 +02:00
parent aa1d58aca2
commit 8f9f0ed87e
2 changed files with 14 additions and 4 deletions

View file

@ -1,14 +1,20 @@
import { spawnSync } from "bun";
import { dependencies } from "../package.json";
import { sliceIfStartsWith } from "./util.ts";
export const COMMIT_HASH = spawnSync({
cmd: ["git", "log", "--pretty=format:%h", "-n", "1"],
}).stdout.toString();
export const LILYBIRD_VERSION = dependencies.lilybird.slice(1);
export const LILYBIRD_JSX_VERSION = dependencies["@lilybird/jsx"].slice(1);
export const LILYBIRD_HANDLERS_VERSION =
dependencies["@lilybird/handlers"].slice(1);
export const LILYBIRD_VERSION = sliceIfStartsWith(dependencies.lilybird, "^");
export const LILYBIRD_JSX_VERSION = sliceIfStartsWith(
dependencies["@lilybird/jsx"],
"^"
);
export const LILYBIRD_HANDLERS_VERSION = sliceIfStartsWith(
dependencies["@lilybird/handlers"],
"^"
);
export const PRODUCTION = process.env.NODE_ENV === "production";

View file

@ -42,3 +42,7 @@ export function isBunOnlyLikeMessage(content?: string) {
export function getRandomBunEmoji() {
return BUN_EMOJIS[Math.floor(Math.random() * BUN_EMOJIS.length)];
}
export function sliceIfStartsWith(input: string, startsWith: string) {
return input.startsWith(startsWith) ? input.slice(startsWith.length) : input;
}