From 099ed898be0c04ebc3fdcd7c440ad36781523a46 Mon Sep 17 00:00:00 2001 From: IvanZosimov Date: Thu, 30 Jun 2022 18:42:04 +0200 Subject: [PATCH] Optimize code --- dist/setup/index.js | 10 ++++------ src/setup-python.ts | 11 ++++------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index 078ff004d..9f8f0d517 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -65271,12 +65271,10 @@ function resolveVersionInput() { } if (versionFile) { if (!fs_1.default.existsSync(versionFile)) { - logWarning(`The specified python version file at: ${versionFile} does not exist. Attempting to find .python-version file.`); - if (!fs_1.default.existsSync('.python-version')) { - throw new Error(`The specified python version file at: ${versionFile} does not exist and default .python-version file isn't found.`); - } - else { - versionFile = '.python-version'; + logWarning(`The specified python version file at: ${versionFile} doesn't exist. Attempting to find .python-version file.`); + versionFile = '.python-version'; + if (!fs_1.default.existsSync(versionFile)) { + throw new Error(`The ${versionFile} doesn't exist.`); } } version = fs_1.default.readFileSync(versionFile, 'utf8'); diff --git a/src/setup-python.ts b/src/setup-python.ts index f1171f923..55bf4971c 100644 --- a/src/setup-python.ts +++ b/src/setup-python.ts @@ -39,14 +39,11 @@ function resolveVersionInput(): string { if (versionFile) { if (!fs.existsSync(versionFile)) { logWarning( - `The specified python version file at: ${versionFile} does not exist. Attempting to find .python-version file.` + `The specified python version file at: ${versionFile} doesn't exist. Attempting to find .python-version file.` ); - if (!fs.existsSync('.python-version')) { - throw new Error( - `The specified python version file at: ${versionFile} does not exist and default .python-version file isn't found.` - ); - } else { - versionFile = '.python-version'; + versionFile = '.python-version'; + if (!fs.existsSync(versionFile)) { + throw new Error(`The ${versionFile} doesn't exist.`); } }