8000 Fix resolveVersionInput() logic · lilyminium/setup-python@b88a682 · GitHub
[go: up one dir, main page]

Skip to content

Commit b88a682

Browse files
author
IvanZosimov
committed
Fix resolveVersionInput() logic
1 parent c474c82 commit b88a682

File tree

2 files changed

+21
-16
lines changed

2 files changed

+21
-16
lines changed

dist/setup/index.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65262,17 +65262,20 @@ function resolveVersionInput() {
6526265262
}
6526365263
if (versionFile) {
6526465264
if (!fs_1.default.existsSync(versionFile)) {
65265-
logWarning(`The specified python version file at: ${versionFile} doesn't exist. Attempting to find .python-version file.`);
65266-
versionFile = '.python-version';
65267-
if (!fs_1.default.existsSync(versionFile)) {
65268-
throw new Error(`The ${versionFile} doesn't exist.`);
65269-
}
65265+
throw new Error(`The specified python version file at: ${versionFile} doesn't exist.`);
6527065266
}
6527165267
version = fs_1.default.readFileSync(versionFile, 'utf8');
6527265268
core.info(`Resolved ${versionFile} as ${version}`);
6527365269
return version;
6527465270
}
65275-
core.warning("Neither 'python-version' nor 'python-version-file' inputs were supplied.");
65271+
logWarning("Neither 'python-version' nor 'python-version-file' inputs were supplied. Attempting to find '.python-version' file.");
65272+
versionFile = '.python-version';
65273+
if (fs_1.default.existsSync(versionFile)) {
65274+
version = fs_1.default.readFileSync(versionFile, 'utf8');
65275+
core.info(`Resolved ${versionFile} as ${version}`);
65276+
return version;
65277+
}
65278+
logWarning(`${versionFile} doesn't exist.`);
6527665279
return version;
6527765280
}
6527865281
function run() {

src/setup-python.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,26 @@ function resolveVersionInput(): string {
3838

3939
if (versionFile) {
4040
if (!fs.existsSync(versionFile)) {
41-
logWarning(
42-
`The specified python version file at: ${versionFile} doesn't exist. Attempting to find .python-version file.`
41+
throw new Error(
42+
`The specified python version file at: ${versionFile} doesn't exist.`
4343
);
44-
versionFile = '.python-version';
45-
if (!fs.existsSync(versionFile)) {
46-
throw new Error(`The ${versionFile} doesn't exist.`);
47-
}
4844
}
49-
5045
version = fs.readFileSync(versionFile, 'utf8');
5146
core.info(`Resolved ${versionFile} as ${version}`);
52-
5347
return version;
5448
}
5549

56-
core.warning(
57-
"Neither 'python-version' nor 'python-version-file' inputs were supplied."
50+
logWarning(
51+
"Neither 'python-version' nor 'python-version-file' inputs were supplied. Attempting to find '.python-version' file."
5852
);
53+
versionFile = '.python-version';
54+
if (fs.existsSync(versionFile)) {
55+
version = fs.readFileSync(versionFile, 'utf8');
56+
core.info(`Resolved ${versionFile} as ${version}`);
57+
return version;
58+
}
59+
60+
logWarning(`${versionFile} doesn't exist.`);
5961

6062
return version;
6163
}

0 commit comments

Comments
 (0)
0