Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed resolveVersionInput() logic #465

Merged
merged 1 commit into from Jul 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 9 additions & 6 deletions dist/setup/index.js
Expand Up @@ -65262,17 +65262,20 @@ function resolveVersionInput() {
}
if (versionFile) {
if (!fs_1.default.existsSync(versionFile)) {
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.`);
}
throw new Error(`The specified python version file at: ${versionFile} doesn't exist.`);
}
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. Attempting to find '.python-version' file.");
versionFile = '.python-version';
if (fs_1.default.existsSync(versionFile)) {
version = fs_1.default.readFileSync(versionFile, 'utf8');
core.info(`Resolved ${versionFile} as ${version}`);
return version;
}
logWarning(`${versionFile} doesn't exist.`);
return version;
}
function run() {
Expand Down
22 changes: 12 additions & 10 deletions src/setup-python.ts
Expand Up @@ -38,24 +38,26 @@ function resolveVersionInput(): string {

if (versionFile) {
if (!fs.existsSync(versionFile)) {
logWarning(
`The specified python version file at: ${versionFile} doesn't exist. Attempting to find .python-version file.`
throw new Error(
`The specified python version file at: ${versionFile} doesn't exist.`
);
versionFile = '.python-version';
if (!fs.existsSync(versionFile)) {
throw new Error(`The ${versionFile} doesn't exist.`);
}
}

version = fs.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. Attempting to find '.python-version' file."
);
versionFile = '.python-version';
if (fs.existsSync(versionFile)) {
version = fs.readFileSync(versionFile, 'utf8');
core.info(`Resolved ${versionFile} as ${version}`);
return version;
}

logWarning(`${versionFile} doesn't exist.`);

return version;
}
Expand Down