forked from lessweb/deepcode-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpackage.ts
More file actions
25 lines (19 loc) · 711 Bytes
/
Copy pathpackage.ts
File metadata and controls
25 lines (19 loc) · 711 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import { readPackageUp, type PackageJson as BasePackageJson } from "read-package-up";
import { fileURLToPath } from "node:url";
import path from "node:path";
import { CLI_VERSION } from "../generated/git-commit";
export type PackageJson = BasePackageJson;
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
let packageJson: PackageJson;
export async function getPackageJson(): Promise<PackageJson> {
if (packageJson) {
return packageJson;
}
const result = await readPackageUp({ cwd: __dirname });
if (!result) {
return { name: "@vegamo/deepcode-cli", version: CLI_VERSION ?? "" };
}
packageJson = result.packageJson;
return packageJson;
}