File tree Expand file tree Collapse file tree 2 files changed +26
-3
lines changed
packages/cli-doctor/src/tools/healthchecks Expand file tree Collapse file tree 2 files changed +26
-3
lines changed Original file line number Diff line number Diff line change @@ -75,6 +75,29 @@ describe('androidSDK', () => {
7575 expect ( diagnostics . needsToBeFixed ) . toBe ( true ) ;
7676 } ) ;
7777
78+ it ( 'reads buildToolsVersion when using more complex definition' , async ( ) => {
79+ // Override mock file
80+ writeFiles ( mockWorkingDir , {
81+ 'android/build.gradle' : `
82+ buildscript {
83+ ext {
84+ buildToolsVersion = findProperty('android.buildToolsVersion') ?: '34.0.0'
85+ minSdkVersion = 16
86+ compileSdkVersion = 28
87+ targetSdkVersion = 28
88+ }
89+ }
90+ ` ,
91+ } ) ;
92+ // @ts -ignore
93+ environmentInfo . SDKs [ 'Android SDK' ] = {
94+ 'Build Tools' : [ '34.0.0' ] ,
95+ } ;
96+ ( execa as unknown as jest . Mock ) . mockResolvedValue ( { stdout : '' } ) ;
97+ const diagnostics = await androidSDK . getDiagnostics ( environmentInfo ) ;
98+ expect ( diagnostics . needsToBeFixed ) . toBe ( false ) ;
99+ } ) ;
100+
78101 it ( 'returns false if the SDK version is in range' , async ( ) => {
79102 // To avoid having to provide fake versions for all the Android SDK tools
80103 // @ts -ignore
Original file line number Diff line number Diff line change @@ -49,9 +49,9 @@ const getBuildToolsVersion = (projectRoot = ''): string => {
4949 // Get only the portion of the declaration of `buildToolsVersion`
5050 . substring ( buildToolsVersionIndex )
5151 . split ( '\n' ) [ 0 ]
52- // Get only the the value of `buildToolsVersion`
53- . match ( / \d | \. . / g) || [ ]
54- ) . join ( '' ) ;
52+ // Get only the value of `buildToolsVersion`
53+ . match ( / \d + \. \d + \. \d + / g) || [ ]
54+ ) . at ( 0 ) ;
5555
5656 return buildToolsVersion || 'Not Found' ;
5757} ;
You can’t perform that action at this time.
0 commit comments