Skip to content

Commit 5fbb819

Browse files
author
IvanZosimov
committed
Optimize logic, rebuild action
1 parent 82eddc4 commit 5fbb819

File tree

2 files changed

+23
-24
lines changed

2 files changed

+23
-24
lines changed

dist/setup/index.js

+11-9
Original file line numberDiff line numberDiff line change
@@ -65241,6 +65241,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
6524165241
return (mod && mod.__esModule) ? mod : { "default": mod };
6524265242
};
6524365243
Object.defineProperty(exports, "__esModule", ({ value: true }));
65244+
exports.logWarning = void 0;
6524465245
const core = __importStar(__nccwpck_require__(2186));
6524565246
const finder = __importStar(__nccwpck_require__(9996));
6524665247
const finderPyPy = __importStar(__nccwpck_require__(4003));
@@ -65269,24 +65270,20 @@ function resolveVersionInput() {
6526965270
return version;
6527065271
}
6527165272
if (versionFile) {
65272-
const defaultVersionFile = '.python-version';
6527365273
if (!fs_1.default.existsSync(versionFile)) {
65274-
if (versionFile === defaultVersionFile) {
65275-
throw new Error(`The specified python version file at: ${versionFile} does not exist.`);
65276-
}
65277-
if (fs_1.default.existsSync(defaultVersionFile)) {
65278-
core.warning(`The specified python version file at: ${versionFile} does not exist. Attempting to find ${defaultVersionFile} file.`);
65279-
versionFile = defaultVersionFile;
65274+
logWarning(`The specified python version file at: ${versionFile} does not exist. Attempting to find .python-version file.`);
65275+
if (!fs_1.default.existsSync('.python-version')) {
65276+
throw new Error(`The specified python version file at: ${versionFile} does not exist and default .python-version file isn't found.`);
6528065277
}
6528165278
else {
65282-
throw new Error(`The specified python version file at: ${versionFile} does not exist and default ${defaultVersionFile} file isn't found.`);
65279+
versionFile = '.python-version';
6528365280
}
6528465281
}
6528565282
version = fs_1.default.readFileSync(versionFile, 'utf8');
6528665283
core.info(`Resolved ${versionFile} as ${version}`);
6528765284
return version;
6528865285
}
65289-
core.warning("Neither 'python-version' nor 'python-version-file' inputs were supplied.");
65286+
logWarning("Neither 'python-version' nor 'python-version-file' inputs were supplied.");
6529065287
return version;
6529165288
}
6529265289
function run() {
@@ -65331,6 +65328,11 @@ function run() {
6533165328
}
6533265329
});
6533365330
}
65331+
function logWarning(message) {
65332+
const warningPrefix = '[warning]';
65333+
core.info(`${warningPrefix}${message}`);
65334+
}
65335+
exports.logWarning = logWarning;
6533465336
run();
6533565337

6533665338

src/setup-python.ts

+12-15
Original file line numberDiff line numberDiff line change
@@ -37,24 +37,16 @@ function resolveVersionInput(): string {
3737
}
3838

3939
if (versionFile) {
40-
const defaultVersionFile = '.python-version';
41-
4240
if (!fs.existsSync(versionFile)) {
43-
if (versionFile === defaultVersionFile) {
41+
logWarning(
42+
`The specified python version file at: ${versionFile} does not exist. Attempting to find .python-version file.`
43+
);
44+
if (!fs.existsSync('.python-version')) {
4445
throw new Error(
45-
`The specified python version file at: ${versionFile} does not exist.`
46-
);
47-
}
48-
49-
if (fs.existsSync(defaultVersionFile)) {
50-
core.warning(
51-
`The specified python version file at: ${versionFile} does not exist. Attempting to find ${defaultVersionFile} file.`
46+
`The specified python version file at: ${versionFile} does not exist and default .python-version file isn't found.`
5247
);
53-
versionFile = defaultVersionFile;
5448
} else {
55-
throw new Error(
56-
`The specified python version file at: ${versionFile} does not exist and default ${defaultVersionFile} file isn't found.`
57-
);
49+
versionFile = '.python-version';
5850
}
5951
}
6052

@@ -64,7 +56,7 @@ function resolveVersionInput(): string {
6456
return version;
6557
}
6658

67-
core.warning(
59+
logWarning(
6860
"Neither 'python-version' nor 'python-version-file' inputs were supplied."
6961
);
7062

@@ -124,4 +116,9 @@ async function run() {
124116
}
125117
}
126118

119+
export function logWarning(message: string): void {
120+
const warningPrefix = '[warning]';
121+
core.info(`${warningPrefix}${message}`);
122+
}
123+
127124
run();

0 commit comments

Comments
 (0)