File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed
packages/react-native-node-api-cmake/src Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change 1+ import chalk from "chalk" ;
2+ import cp from "node:child_process" ;
3+
4+ export function getNinjaVersion ( ) : string | undefined {
5+ try {
6+ const ninjaVersion = cp
7+ . execSync ( "ninja --version" , {
8+ encoding : "utf-8" ,
9+ stdio : "pipe" ,
10+ } )
11+ . trim ( ) ;
12+ return ninjaVersion ;
13+ } catch {
14+ return undefined ;
15+ }
16+ }
17+
18+ let ninjaAvailable : boolean | undefined ;
19+
20+ export function isNinjaAvailable ( log = true ) : boolean {
21+ if ( typeof ninjaAvailable === "boolean" ) {
22+ return ninjaAvailable ;
23+ }
24+
25+ const ninjaVersion = getNinjaVersion ( ) ;
26+ ninjaAvailable = typeof ninjaVersion === "string" ;
27+
28+ if ( log && ninjaAvailable ) {
29+ console . log ( chalk . dim ( `Using Ninja ${ ninjaVersion } for Android builds` ) ) ;
30+ } else if ( log && ! ninjaAvailable ) {
31+ console . log (
32+ `Using Unix Makefiles as fallback, as Ninja was not found.\n${ chalk . dim (
33+ "Install Ninja for faster builds."
34+ ) } `
35+ ) ;
36+ }
37+
38+ return ninjaAvailable ;
39+ }
You can’t perform that action at this time.
0 commit comments