File tree Expand file tree Collapse file tree
packages/cli-config-android/src/config Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -25,13 +25,13 @@ describe('findBuildGradle for apps', () => {
2525 } ) ;
2626
2727 it ( 'returns the app gradle path if file exists in the folder' , ( ) => {
28- expect ( findBuildGradle ( '/flat/android' , false ) ) . toBe (
28+ expect ( findBuildGradle ( '/flat/android' , 'app' ) ) . toBe (
2929 '/flat/android/app/build.gradle' ,
3030 ) ;
3131 } ) ;
3232
3333 it ( 'returns `null` if there is no gradle in the app folder' , ( ) => {
34- expect ( findBuildGradle ( '/empty' , false ) ) . toBeNull ( ) ;
34+ expect ( findBuildGradle ( '/empty' , 'app' ) ) . toBeNull ( ) ;
3535 } ) ;
3636} ) ;
3737
@@ -46,12 +46,12 @@ describe('findBuildGradle for libraries', () => {
4646 } ) ;
4747
4848 it ( 'returns the app gradle path if file exists in the folder' , ( ) => {
49- expect ( findBuildGradle ( '/flat/android' , true ) ) . toBe (
49+ expect ( findBuildGradle ( '/flat/android' , '' ) ) . toBe (
5050 '/flat/android/build.gradle' ,
5151 ) ;
5252 } ) ;
5353
5454 it ( 'returns `null` if there is no gradle in the app folder' , ( ) => {
55- expect ( findBuildGradle ( '/empty' , true ) ) . toBeNull ( ) ;
55+ expect ( findBuildGradle ( '/empty' , '' ) ) . toBeNull ( ) ;
5656 } ) ;
5757} ) ;
Original file line number Diff line number Diff line change 11import fs from 'fs' ;
22import path from 'path' ;
33
4- export function findBuildGradle ( sourceDir : string , isLibrary : boolean ) {
4+ /**
5+ * Find the build.gradle file for the given app name.
6+ * This helper is used to find build.gradle file in both apps and libraries.
7+ * For libraries, the appName is empty string.
8+ */
9+ export function findBuildGradle ( sourceDir : string , appName : string ) {
510 const buildGradlePath = path . join (
611 sourceDir ,
7- isLibrary ? 'build.gradle' : 'app/ build.gradle',
12+ path . join ( appName , ' build.gradle') ,
813 ) ;
914 const buildGradleKtsPath = path . join (
1015 sourceDir ,
11- isLibrary ? 'build.gradle.kts' : 'app/ build.gradle.kts',
16+ path . join ( appName , ' build.gradle.kts') ,
1217 ) ;
1318
1419 if ( fs . existsSync ( buildGradlePath ) ) {
Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ export function projectConfig(
4848 const manifestPath = userConfig . manifestPath
4949 ? path . join ( sourceDir , userConfig . manifestPath )
5050 : findManifest ( path . join ( sourceDir , appName ) ) ;
51- const buildGradlePath = findBuildGradle ( sourceDir , false ) ;
51+ const buildGradlePath = findBuildGradle ( sourceDir , appName ) ;
5252
5353 if ( ! manifestPath && ! buildGradlePath ) {
5454 return null ;
@@ -125,7 +125,7 @@ export function dependencyConfig(
125125 const manifestPath = userConfig . manifestPath
126126 ? path . join ( sourceDir , userConfig . manifestPath )
127127 : findManifest ( sourceDir ) ;
128- const buildGradlePath = findBuildGradle ( sourceDir , true ) ;
128+ const buildGradlePath = findBuildGradle ( sourceDir , '' ) ;
129129 const isPureCxxDependency =
130130 userConfig . cxxModuleCMakeListsModuleName != null &&
131131 userConfig . cxxModuleCMakeListsPath != null &&
You can’t perform that action at this time.
0 commit comments