-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathninja.ts
More file actions
39 lines (33 loc) · 941 Bytes
/
ninja.ts
File metadata and controls
39 lines (33 loc) · 941 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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import chalk from "chalk";
import cp from "node:child_process";
export function getNinjaVersion(): string | undefined {
try {
const ninjaVersion = cp
.execSync("ninja --version", {
encoding: "utf-8",
stdio: "pipe",
})
.trim();
return ninjaVersion;
} catch {
return undefined;
}
}
let ninjaAvailable: boolean | undefined;
export function isNinjaAvailable(log = true): boolean {
if (typeof ninjaAvailable === "boolean") {
return ninjaAvailable;
}
const ninjaVersion = getNinjaVersion();
ninjaAvailable = typeof ninjaVersion === "string";
if (log && ninjaAvailable) {
console.log(chalk.dim(`Using Ninja ${ninjaVersion} for Android builds`));
} else if (log && !ninjaAvailable) {
console.log(
`Using Unix Makefiles as fallback, as Ninja was not found.\n${chalk.dim(
"Install Ninja for faster builds."
)}`
);
}
return ninjaAvailable;
}