mirror of
https://github.com/actions/setup-python.git
synced 2024-11-25 10:26:54 +01:00
Fix bug in resolveVersionInput()
This commit is contained in:
parent
ab6deb310f
commit
afd3e72a25
2 changed files with 41 additions and 13 deletions
22
dist/setup/index.js
vendored
22
dist/setup/index.js
vendored
|
@ -64471,12 +64471,24 @@ function resolveVersionInput() {
|
||||||
if (version) {
|
if (version) {
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
versionFile = versionFile || '.python-version';
|
if (versionFile) {
|
||||||
if (!fs_1.default.existsSync(versionFile)) {
|
const defaultVersionFile = '.python-version';
|
||||||
throw new Error(`The specified python version file at: ${versionFile} does not exist`);
|
const VersionFileExists = fs_1.default.existsSync(versionFile);
|
||||||
|
const defaultVersionFileExists = fs_1.default.existsSync(defaultVersionFile);
|
||||||
|
if (!VersionFileExists && !defaultVersionFileExists) {
|
||||||
|
throw new Error(`The specified python version file at: ${versionFile} does not exist and default ${defaultVersionFile} file isn't found`);
|
||||||
|
}
|
||||||
|
if (VersionFileExists) {
|
||||||
|
version = fs_1.default.readFileSync(versionFile, 'utf8');
|
||||||
|
core.info(`Resolved ${versionFile} as ${version}`);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
version = fs_1.default.readFileSync('.python-version', 'utf8');
|
||||||
|
core.info(`Resolved ${'.python-version'} as ${version}`);
|
||||||
|
}
|
||||||
|
return version;
|
||||||
}
|
}
|
||||||
version = fs_1.default.readFileSync(versionFile, 'utf8');
|
core.warning("Neither 'python-version' nor 'python-version-file' inputs were supplied. ");
|
||||||
core.info(`Resolved ${versionFile} as ${version}`);
|
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
function run() {
|
function run() {
|
||||||
|
|
|
@ -36,15 +36,31 @@ function resolveVersionInput(): string {
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
versionFile = versionFile || '.python-version';
|
if (versionFile) {
|
||||||
if (!fs.existsSync(versionFile)) {
|
const defaultVersionFile = '.python-version';
|
||||||
throw new Error(
|
|
||||||
`The specified python version file at: ${versionFile} does not exist`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
version = fs.readFileSync(versionFile, 'utf8');
|
|
||||||
core.info(`Resolved ${versionFile} as ${version}`);
|
|
||||||
|
|
||||||
|
const VersionFileExists = fs.existsSync(versionFile);
|
||||||
|
const defaultVersionFileExists = fs.existsSync(defaultVersionFile);
|
||||||
|
|
||||||
|
if (!VersionFileExists && !defaultVersionFileExists) {
|
||||||
|
throw new Error(
|
||||||
|
`The specified python version file at: ${versionFile} does not exist and default ${defaultVersionFile} file isn't found`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (VersionFileExists) {
|
||||||
|
version = fs.readFileSync(versionFile, 'utf8');
|
||||||
|
core.info(`Resolved ${versionFile} as ${version}`);
|
||||||
|
} else {
|
||||||
|
version = fs.readFileSync('.python-version', 'utf8');
|
||||||
|
core.info(`Resolved ${'.python-version'} as ${version}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
|
core.warning(
|
||||||
|
"Neither 'python-version' nor 'python-version-file' inputs were supplied. "
|
||||||
|
);
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue