mirror of
https://github.com/actions/setup-python.git
synced 2024-12-28 02:15:23 +01:00
Rearrange logic
This commit is contained in:
parent
56f6060254
commit
84087f5301
1 changed files with 17 additions and 13 deletions
|
@ -39,28 +39,32 @@ function resolveVersionInput(): string {
|
||||||
if (versionFile) {
|
if (versionFile) {
|
||||||
const defaultVersionFile = '.python-version';
|
const defaultVersionFile = '.python-version';
|
||||||
|
|
||||||
const versionFileExists = fs.existsSync(versionFile);
|
if (!fs.existsSync(versionFile)) {
|
||||||
const defaultVersionFileExists = fs.existsSync(defaultVersionFile);
|
if (versionFile === defaultVersionFile) {
|
||||||
|
throw new Error(
|
||||||
|
`The specified python version file at: ${versionFile} does not exist.`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (!versionFileExists && !defaultVersionFileExists) {
|
if (fs.existsSync(defaultVersionFile)) {
|
||||||
throw new Error(
|
versionFile = defaultVersionFile;
|
||||||
`The specified python version file at: ${versionFile} does not exist and default ${defaultVersionFile} file isn't found`
|
} else {
|
||||||
);
|
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(defaultVersionFile, 'utf8');
|
|
||||||
core.info(`Resolved ${defaultVersionFile} as ${version}`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
version = fs.readFileSync(versionFile, 'utf8');
|
||||||
|
core.info(`Resolved ${versionFile} as ${version}`);
|
||||||
|
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
core.warning(
|
core.warning(
|
||||||
"Neither 'python-version' nor 'python-version-file' inputs were supplied. "
|
"Neither 'python-version' nor 'python-version-file' inputs were supplied. "
|
||||||
);
|
);
|
||||||
|
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue