mirror of
https://github.com/actions/setup-python.git
synced 2024-11-28 18:10:55 -05:00
Merge pull request #465 from IvanZosimov/pythonversionfile
Fixed resolveVersionInput() logic
This commit is contained in:
commit
aba6f4ba7b
2 changed files with 21 additions and 16 deletions
15
dist/setup/index.js
vendored
15
dist/setup/index.js
vendored
|
@ -65262,17 +65262,20 @@ function resolveVersionInput() {
|
||||||
}
|
}
|
||||||
if (versionFile) {
|
if (versionFile) {
|
||||||
if (!fs_1.default.existsSync(versionFile)) {
|
if (!fs_1.default.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_1.default.existsSync(versionFile)) {
|
|
||||||
throw new Error(`The ${versionFile} doesn't exist.`);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
version = fs_1.default.readFileSync(versionFile, 'utf8');
|
version = fs_1.default.readFileSync(versionFile, 'utf8');
|
||||||
core.info(`Resolved ${versionFile} as ${version}`);
|
core.info(`Resolved ${versionFile} as ${version}`);
|
||||||
return 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;
|
return version;
|
||||||
}
|
}
|
||||||
function run() {
|
function run() {
|
||||||
|
|
|
@ -38,24 +38,26 @@ function resolveVersionInput(): string {
|
||||||
|
|
||||||
if (versionFile) {
|
if (versionFile) {
|
||||||
if (!fs.existsSync(versionFile)) {
|
if (!fs.existsSync(versionFile)) {
|
||||||
logWarning(
|
throw new Error(
|
||||||
`The specified python version file at: ${versionFile} doesn't exist. Attempting to find .python-version file.`
|
`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');
|
version = fs.readFileSync(versionFile, 'utf8');
|
||||||
core.info(`Resolved ${versionFile} as ${version}`);
|
core.info(`Resolved ${versionFile} as ${version}`);
|
||||||
|
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
core.warning(
|
logWarning(
|
||||||
"Neither 'python-version' nor 'python-version-file' inputs were supplied."
|
"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;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue