mirror of
https://github.com/actions/setup-python.git
synced 2024-11-14 07:31:09 +07:00
Merge pull request #450 from IvanZosimov/ResolveVersionFix
Rearranged logic of the ResolveVersionInput()
This commit is contained in:
commit
782f81b91d
25
dist/setup/index.js
vendored
25
dist/setup/index.js
vendored
@ -65241,6 +65241,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
|
exports.logWarning = void 0;
|
||||||
const core = __importStar(__nccwpck_require__(2186));
|
const core = __importStar(__nccwpck_require__(2186));
|
||||||
const finder = __importStar(__nccwpck_require__(9996));
|
const finder = __importStar(__nccwpck_require__(9996));
|
||||||
const finderPyPy = __importStar(__nccwpck_require__(4003));
|
const finderPyPy = __importStar(__nccwpck_require__(4003));
|
||||||
@ -65263,17 +65264,24 @@ function resolveVersionInput() {
|
|||||||
let version = core.getInput('python-version');
|
let version = core.getInput('python-version');
|
||||||
let versionFile = core.getInput('python-version-file');
|
let versionFile = core.getInput('python-version-file');
|
||||||
if (version && versionFile) {
|
if (version && versionFile) {
|
||||||
core.warning('Both python-version and python-version-file inputs are specified, only python-version will be used');
|
core.warning('Both python-version and python-version-file inputs are specified, only python-version will be used.');
|
||||||
}
|
}
|
||||||
if (version) {
|
if (version) {
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
versionFile = versionFile || '.python-version';
|
if (versionFile) {
|
||||||
if (!fs_1.default.existsSync(versionFile)) {
|
if (!fs_1.default.existsSync(versionFile)) {
|
||||||
throw new Error(`The specified python version file at: ${versionFile} does not exist`);
|
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.`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
version = fs_1.default.readFileSync(versionFile, 'utf8');
|
||||||
|
core.info(`Resolved ${versionFile} 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() {
|
||||||
@ -65318,6 +65326,11 @@ function run() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
function logWarning(message) {
|
||||||
|
const warningPrefix = '[warning]';
|
||||||
|
core.info(`${warningPrefix}${message}`);
|
||||||
|
}
|
||||||
|
exports.logWarning = logWarning;
|
||||||
run();
|
run();
|
||||||
|
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ function resolveVersionInput(): string {
|
|||||||
|
|
||||||
if (version && versionFile) {
|
if (version && versionFile) {
|
||||||
core.warning(
|
core.warning(
|
||||||
'Both python-version and python-version-file inputs are specified, only python-version will be used'
|
'Both python-version and python-version-file inputs are specified, only python-version will be used.'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,14 +36,26 @@ function resolveVersionInput(): string {
|
|||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
versionFile = versionFile || '.python-version';
|
if (versionFile) {
|
||||||
if (!fs.existsSync(versionFile)) {
|
if (!fs.existsSync(versionFile)) {
|
||||||
throw new Error(
|
logWarning(
|
||||||
`The specified python version file at: ${versionFile} does not exist`
|
`The specified python version file at: ${versionFile} doesn't exist. Attempting to find .python-version file.`
|
||||||
);
|
);
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
version = fs.readFileSync(versionFile, 'utf8');
|
|
||||||
core.info(`Resolved ${versionFile} as ${version}`);
|
core.warning(
|
||||||
|
"Neither 'python-version' nor 'python-version-file' inputs were supplied."
|
||||||
|
);
|
||||||
|
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
@ -101,4 +113,9 @@ async function run() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function logWarning(message: string): void {
|
||||||
|
const warningPrefix = '[warning]';
|
||||||
|
core.info(`${warningPrefix}${message}`);
|
||||||
|
}
|
||||||
|
|
||||||
run();
|
run();
|
||||||
|
Loading…
Reference in New Issue
Block a user