push
github
59 of 75 branches covered (0.0%)
Branch coverage included in aggregate %.
2089 of 3245 relevant lines covered (64.38%)
2.01 hits per line
1 |
import { readFile } from "fs/promises";
|
3✔ |
2 |
import { Keyable } from "../interfaces/keyable.js";
|
3✔ |
3 |
|
3✔ |
4 |
export class LokalisePkg { |
3✔ |
5 |
static pkgPath() {
|
|
6 |
return "../../package.json"; |
6✔ |
7 |
} |
6✔ |
8 |
|
3✔ |
9 |
static async getVersion(): Promise<string> { |
|
10 |
let pkg: Keyable | null; |
6✔ |
11 |
|
6✔ |
12 |
try {
|
6✔ |
13 |
pkg = JSON.parse( |
6✔ |
14 |
( |
6✔ |
15 |
await readFile(new URL(LokalisePkg.pkgPath(), import.meta.url))
|
6✔ |
16 |
).toString(), |
6✔ |
17 |
); |
6✔ |
18 |
} catch (_e) {
|
|
19 |
pkg = null; |
× |
20 |
} |
× |
21 |
|
6✔ |
22 |
return pkg ? pkg.version : "unknown"; |
|
23 |
} |
6✔ |
24 |
} |
3✔ |