mirror of
https://gitea.com/actions/setup-python.git
synced 2024-11-23 02:29:35 +01:00
Optimize logic, rebuild action
This commit is contained in:
parent
82eddc4023
commit
5fbb819407
2 changed files with 23 additions and 24 deletions
20
dist/setup/index.js
vendored
20
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));
|
||||||
|
@ -65269,24 +65270,20 @@ function resolveVersionInput() {
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
if (versionFile) {
|
if (versionFile) {
|
||||||
const defaultVersionFile = '.python-version';
|
|
||||||
if (!fs_1.default.existsSync(versionFile)) {
|
if (!fs_1.default.existsSync(versionFile)) {
|
||||||
if (versionFile === defaultVersionFile) {
|
logWarning(`The specified python version file at: ${versionFile} does not exist. Attempting to find .python-version file.`);
|
||||||
throw new Error(`The specified python version file at: ${versionFile} does not exist.`);
|
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.`);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
else {
|
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');
|
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.");
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
function run() {
|
function run() {
|
||||||
|
@ -65331,6 +65328,11 @@ function run() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
function logWarning(message) {
|
||||||
|
const warningPrefix = '[warning]';
|
||||||
|
core.info(`${warningPrefix}${message}`);
|
||||||
|
}
|
||||||
|
exports.logWarning = logWarning;
|
||||||
run();
|
run();
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -37,24 +37,16 @@ function resolveVersionInput(): string {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (versionFile) {
|
if (versionFile) {
|
||||||
const defaultVersionFile = '.python-version';
|
|
||||||
|
|
||||||
if (!fs.existsSync(versionFile)) {
|
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(
|
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 {
|
} else {
|
||||||
throw new Error(
|
versionFile = '.python-version';
|
||||||
`The specified python version file at: ${versionFile} does not exist and default ${defaultVersionFile} file isn't found.`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +56,7 @@ function resolveVersionInput(): string {
|
||||||
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."
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -124,4 +116,9 @@ async function run() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function logWarning(message: string): void {
|
||||||
|
const warningPrefix = '[warning]';
|
||||||
|
core.info(`${warningPrefix}${message}`);
|
||||||
|
}
|
||||||
|
|
||||||
run();
|
run();
|
||||||
|
|
Loading…
Reference in a new issue