@@ -50,8 +50,9 @@ function getTmpDir() {
5050 fs . accessSync ( "/tmp" , fs . constants . R_OK | fs . constants . W_OK ) ;
5151 return "/tmp" ;
5252 } catch {
53- console . error ( "Error: No usable temporary directory found (TMPDIR or /tmp not accessible)." ) ;
54- process . exit ( 1 ) ;
53+ console . log ( "Error: No usable temporary directory found (TMPDIR or /tmp not accessible)." ) ;
54+ return null ;
55+ // process.exit(1);
5556 }
5657}
5758
@@ -70,18 +71,32 @@ function patchTargetSdkVersion() {
7071
7172 if ( sdkRegex . test ( content ) ) {
7273 let api = "35" ;
73- const froidFlag = path . join ( getTmpDir ( ) , 'fdroid.bool' ) ;
74+ const tmp = getTmpDir ( ) ;
75+ if ( tmp == null ) {
76+ console . warn ( "---------------------------------------------------------------------------------\n\n\n\n" ) ;
77+ console . warn ( `⚠️ fdroid.bool not found` ) ;
78+ console . warn ( "⚠️ Fdroid flavour will be built" ) ;
79+ api = "28" ;
80+ console . warn ( "\n\n\n\n---------------------------------------------------------------------------------" ) ;
81+ } else {
82+ const froidFlag = path . join ( getTmpDir ( ) , 'fdroid.bool' ) ;
7483
75- if ( fs . existsSync ( froidFlag ) ) {
76- const fdroid = fs . readFileSync ( froidFlag , 'utf-8' ) . trim ( ) ;
77- if ( fdroid == "true" ) {
84+ if ( fs . existsSync ( froidFlag ) ) {
85+ const fdroid = fs . readFileSync ( froidFlag , 'utf-8' ) . trim ( ) ;
86+ if ( fdroid == "true" ) {
87+ api = "28" ;
88+ }
89+ } else {
90+ console . warn ( "---------------------------------------------------------------------------------\n\n\n\n" ) ;
91+ console . warn ( `⚠️ fdroid.bool not found` ) ;
92+ console . warn ( "⚠️ Fdroid flavour will be built" ) ;
7893 api = "28" ;
94+ console . warn ( "\n\n\n\n---------------------------------------------------------------------------------" ) ;
95+ //process.exit(1);
7996 }
80- } else {
81- console . error ( `${ getTmpDir ( ) } /fdroid.bool not found` ) ;
82- process . exit ( 1 ) ;
8397 }
8498
99+
85100 content = content . replace ( sdkRegex , 'targetSdkVersion ' + api ) ;
86101 fs . writeFileSync ( gradleFile , content , 'utf-8' ) ;
87102 console . log ( '[Cordova Hook] ✅ Patched targetSdkVersion to ' + api ) ;
0 commit comments