@@ -21,7 +21,15 @@ export class AndroidPluginBuildService implements IAndroidPluginBuildService {
2121
2222 private getAndroidSourceDirectories ( source : string ) : Array < string > {
2323 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 ;
2533 }
2634
2735 private getManifest ( platformsDir : string ) {
@@ -92,27 +100,6 @@ export class AndroidPluginBuildService implements IAndroidPluginBuildService {
92100 return promise ;
93101 }
94102
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-
116103 private copyRecursive ( source : string , destination : string ) {
117104 shell . cp ( "-R" , source , destination ) ;
118105 }
@@ -246,7 +233,7 @@ export class AndroidPluginBuildService implements IAndroidPluginBuildService {
246233 const dirName = dirNameParts [ dirNameParts . length - 1 ] ;
247234
248235 const destination = path . join ( newPluginMainSrcDir , dirName ) ;
249- this . createDirIfDoesntExist ( destination ) ;
236+ this . $fs . ensureDirectoryExists ( destination ) ;
250237
251238 this . copyRecursive ( path . join ( dir , "*" ) , destination ) ;
252239 }
@@ -336,6 +323,7 @@ export class AndroidPluginBuildService implements IAndroidPluginBuildService {
336323 try {
337324 const newIncludeGradleFileContent = includeGradleFileContent . replace ( productFlavorsScope , "" ) ;
338325 this . $fs . writeFile ( includeGradleFilePath , newIncludeGradleFileContent ) ;
326+
339327 } catch ( e ) {
340328 throw Error ( `Failed to write the updated include.gradle in - ${ includeGradleFilePath } ` ) ;
341329 }
0 commit comments