Optimize logic, rebuild action

This commit is contained in:
IvanZosimov 2022-06-30 17:32:12 +02:00
parent 82eddc4023
commit 5fbb819407
2 changed files with 23 additions and 24 deletions

20
dist/setup/index.js vendored
View File

@ -65241,6 +65241,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.logWarning = void 0;
const core = __importStar(__nccwpck_require__(2186));
const finder = __importStar(__nccwpck_require__(9996));
const finderPyPy = __importStar(__nccwpck_require__(4003));
@ -65269,24 +65270,20 @@ function resolveVersionInput() {
return version;
}
if (versionFile) {
const defaultVersionFile = '.python-version';
if (!fs_1.default.existsSync(versionFile)) {
if (versionFile === defaultVersionFile) {
throw new Error(`The specified python version file at: ${versionFile} does not exist.`);
}
if (fs_1.default.existsSync(defaultVersionFile)) {
core.warning(`The specified python version file at: ${versionFile} does not exist. Attempting to find ${defaultVersionFile} file.`);
versionFile = defaultVersionFile;
logWarning(`The specified python version file at: ${versionFile} does not exist. Attempting to find .python-version file.`);
if (!fs_1.default.existsSync('.python-version')) {
throw new Error(`The specified python version file at: ${versionFile} does not exist and default .python-version 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.`);
versionFile = '.python-version';
}
}
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.");
return version;
}
function run() {
@ -65331,6 +65328,11 @@ function run() {
}
});
}
function logWarning(message) {
const warningPrefix = '[warning]';
core.info(`${warningPrefix}${message}`);
}
exports.logWarning = logWarning;
run();

View File

@ -37,24 +37,16 @@ function resolveVersionInput(): string {
}
if (versionFile) {
const defaultVersionFile = '.python-version';
if (!fs.existsSync(versionFile)) {
if (versionFile === defaultVersionFile) {
logWarning(
`The specified python version file at: ${versionFile} does not exist. Attempting to find .python-version file.`
);
if (!fs.existsSync('.python-version')) {
throw new Error(
`The specified python version file at: ${versionFile} does not exist.`
`The specified python version file at: ${versionFile} does not exist and default .python-version file isn't found.`
);
}
if (fs.existsSync(defaultVersionFile)) {
core.warning(
`The specified python version file at: ${versionFile} does not exist. Attempting to find ${defaultVersionFile} file.`
);
versionFile = defaultVersionFile;
} else {
throw new Error(
`The specified python version file at: ${versionFile} does not exist and default ${defaultVersionFile} file isn't found.`
);
versionFile = '.python-version';
}
}
@ -64,7 +56,7 @@ function resolveVersionInput(): string {
return version;
}
core.warning(
logWarning(
"Neither 'python-version' nor 'python-version-file' inputs were supplied."
);
@ -124,4 +116,9 @@ async function run() {
}
}
export function logWarning(message: string): void {
const warningPrefix = '[warning]';
core.info(`${warningPrefix}${message}`);
}
run();