@@ -21,7 +21,15 @@ export class AndroidPluginBuildService implements IAndroidPluginBuildService {
21
21
22
22
private getAndroidSourceDirectories ( source : string ) : Array < string > {
23
23
const directories = [ "res" , "java" , "assets" , "jniLibs" ] ;
24
- return this . $fs . enumerateFilesInDirectorySync ( source , ( file , stat ) => stat . isDirectory ( ) && _ . includes ( directories , file ) ) ;
24
+ const resultArr : Array < string > = [ ] ;
25
+ this . $fs . enumerateFilesInDirectorySync ( source , ( file , stat ) => {
26
+ if ( stat . isDirectory ( ) && _ . some ( directories , ( element ) => file . endsWith ( element ) ) ) {
27
+ resultArr . push ( file ) ;
28
+ return true ;
29
+ }
30
+ } ) ;
31
+
32
+ return resultArr ;
25
33
}
26
34
27
35
private getManifest ( platformsDir : string ) {
@@ -92,27 +100,6 @@ export class AndroidPluginBuildService implements IAndroidPluginBuildService {
92
100
return promise ;
93
101
}
94
102
95
- private createDirIfDoesntExist ( dirPath : string , { isRelativeToScript = false } = { } ) {
96
- const sep = path . sep ;
97
- const initDir = path . isAbsolute ( dirPath ) ? sep : '' ;
98
- const baseDir = isRelativeToScript ? __dirname : '.' ;
99
-
100
- dirPath . split ( sep ) . reduce ( ( parentDir : string , childDir : string ) => {
101
- const curDir = path . resolve ( baseDir , parentDir , childDir ) ;
102
- try {
103
- if ( ! this . $fs . exists ( curDir ) ) {
104
- this . $fs . createDirectory ( curDir ) ;
105
- }
106
- } catch ( err ) {
107
- if ( err . code !== 'EEXIST' ) {
108
- throw err ;
109
- }
110
- }
111
-
112
- return curDir ;
113
- } , initDir ) ;
114
- }
115
-
116
103
private copyRecursive ( source : string , destination : string ) {
117
104
shell . cp ( "-R" , source , destination ) ;
118
105
}
@@ -246,7 +233,7 @@ export class AndroidPluginBuildService implements IAndroidPluginBuildService {
246
233
const dirName = dirNameParts [ dirNameParts . length - 1 ] ;
247
234
248
235
const destination = path . join ( newPluginMainSrcDir , dirName ) ;
249
- this . createDirIfDoesntExist ( destination ) ;
236
+ this . $fs . ensureDirectoryExists ( destination ) ;
250
237
251
238
this . copyRecursive ( path . join ( dir , "*" ) , destination ) ;
252
239
}
@@ -336,6 +323,7 @@ export class AndroidPluginBuildService implements IAndroidPluginBuildService {
336
323
try {
337
324
const newIncludeGradleFileContent = includeGradleFileContent . replace ( productFlavorsScope , "" ) ;
338
325
this . $fs . writeFile ( includeGradleFilePath , newIncludeGradleFileContent ) ;
326
+
339
327
} catch ( e ) {
340
328
throw Error ( `Failed to write the updated include.gradle in - ${ includeGradleFilePath } ` ) ;
341
329
}
0 commit comments