From 00dbb341f00fd21b088251ff960eac927d0a26e3 Mon Sep 17 00:00:00 2001 From: Vilius Sutkus '89 Date: Wed, 3 Aug 2022 15:02:48 +0300 Subject: [PATCH] [2/2] Read version of cmdline-tools/latest, if version is correct - use it --- dist/index.js | 6 +++--- src/main.ts | 11 +++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/dist/index.js b/dist/index.js index 4f212e0..677f9c0 100644 --- a/dist/index.js +++ b/dist/index.js @@ -8591,9 +8591,9 @@ function findPreinstalledSdkManager() { if (result.isFound) { const propertiesFile = path.join(ANDROID_SDK_ROOT, 'cmdline-tools', 'latest', 'source.properties'); if (fs.existsSync(propertiesFile)) { - const correctRevisionString = `Pkg.Revision=${CMDLINE_TOOLS_VERSION}`; - console.log(correctRevisionString); - result.isCorrectVersion = fs.readFileSync(propertiesFile, 'utf8').includes(correctRevisionString); + result.isCorrectVersion = fs + .readFileSync(propertiesFile, 'utf8') + .includes(`Pkg.Revision=${CMDLINE_TOOLS_VERSION}`); } return result; } diff --git a/src/main.ts b/src/main.ts index 14d5dbb..e8f0f6b 100644 --- a/src/main.ts +++ b/src/main.ts @@ -48,6 +48,17 @@ function findPreinstalledSdkManager(): { result.exePath = getSdkManagerPath('latest') result.isFound = fs.existsSync(result.exePath) if (result.isFound) { + const propertiesFile = path.join( + ANDROID_SDK_ROOT, + 'cmdline-tools', + 'latest', + 'source.properties' + ) + if (fs.existsSync(propertiesFile)) { + result.isCorrectVersion = fs + .readFileSync(propertiesFile, 'utf8') + .includes(`Pkg.Revision=${CMDLINE_TOOLS_VERSION}`) + } return result } result.exePath = ''