mirror of
https://github.com/better-auth/better-auth.git
synced 2026-05-23 15:42:09 -05:00
20 lines
579 B
TypeScript
20 lines
579 B
TypeScript
import fs from "node:fs/promises";
|
|
import path from "node:path";
|
|
import type { PackageJson } from "type-fest";
|
|
|
|
const rootDir = path.resolve(import.meta.dirname, "..");
|
|
|
|
const getCliPath = async () => {
|
|
const pkgJson: PackageJson = JSON.parse(
|
|
await fs.readFile(path.join(rootDir, "package.json"), "utf-8"),
|
|
);
|
|
// Handle both string and object bin formats
|
|
const binPath =
|
|
typeof pkgJson.bin === "string"
|
|
? pkgJson.bin
|
|
: (Object.values(pkgJson.bin ?? {})[0] ?? "./dist/index.mjs");
|
|
return path.join(rootDir, binPath);
|
|
};
|
|
|
|
export const cliPath = await getCliPath();
|