diff --git a/dist/setup/index.js b/dist/setup/index.js index f439423..474ce59 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -65241,6 +65241,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.logWarning = void 0; const core = __importStar(__nccwpck_require__(2186)); const finder = __importStar(__nccwpck_require__(9996)); const finderPyPy = __importStar(__nccwpck_require__(4003)); @@ -65269,24 +65270,20 @@ function resolveVersionInput() { return version; } if (versionFile) { - const defaultVersionFile = '.python-version'; if (!fs_1.default.existsSync(versionFile)) { - if (versionFile === defaultVersionFile) { - throw new Error(`The specified python version file at: ${versionFile} does not exist.`); - } - if (fs_1.default.existsSync(defaultVersionFile)) { - core.warning(`The specified python version file at: ${versionFile} does not exist. Attempting to find ${defaultVersionFile} file.`); - versionFile = defaultVersionFile; + 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 { - throw new Error(`The specified python version file at: ${versionFile} does not exist and default ${defaultVersionFile} file isn't found.`); + versionFile = '.python-version'; } } version = fs_1.default.readFileSync(versionFile, 'utf8'); core.info(`Resolved ${versionFile} as ${version}`); return version; } - core.warning("Neither 'python-version' nor 'python-version-file' inputs were supplied."); + logWarning("Neither 'python-version' nor 'python-version-file' inputs were supplied."); return version; } function run() { @@ -65331,6 +65328,11 @@ function run() { } }); } +function logWarning(message) { + const warningPrefix = '[warning]'; + core.info(`${warningPrefix}${message}`); +} +exports.logWarning = logWarning; run(); diff --git a/src/setup-python.ts b/src/setup-python.ts index c4db766..22c407b 100644 --- a/src/setup-python.ts +++ b/src/setup-python.ts @@ -37,24 +37,16 @@ function resolveVersionInput(): string { } if (versionFile) { - const defaultVersionFile = '.python-version'; - if (!fs.existsSync(versionFile)) { - if (versionFile === defaultVersionFile) { + logWarning( + `The specified python version file at: ${versionFile} does not 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.` + `The specified python version file at: ${versionFile} does not exist and default .python-version file isn't found.` ); - } - - if (fs.existsSync(defaultVersionFile)) { - core.warning( - `The specified python version file at: ${versionFile} does not exist. Attempting to find ${defaultVersionFile} file.` - ); - versionFile = defaultVersionFile; } else { - throw new Error( - `The specified python version file at: ${versionFile} does not exist and default ${defaultVersionFile} file isn't found.` - ); + versionFile = '.python-version'; } } @@ -64,7 +56,7 @@ function resolveVersionInput(): string { return version; } - core.warning( + logWarning( "Neither 'python-version' nor 'python-version-file' inputs were supplied." ); @@ -124,4 +116,9 @@ async function run() { } } +export function logWarning(message: string): void { + const warningPrefix = '[warning]'; + core.info(`${warningPrefix}${message}`); +} + run();