mirror of
https://github.com/actions/setup-python.git
synced 2026-05-14 16:39:48 +00:00
optimize code
This commit is contained in:
Vendored
+2
-5
@@ -100729,7 +100729,6 @@ function getVersionInputFromToolVersions(versionFile) {
|
||||
try {
|
||||
const fileContents = fs_1.default.readFileSync(versionFile, 'utf8');
|
||||
const lines = fileContents.split('\n');
|
||||
const versions = [];
|
||||
for (const line of lines) {
|
||||
// Skip commented lines
|
||||
if (line.trim().startsWith('#')) {
|
||||
@@ -100740,10 +100739,8 @@ function getVersionInputFromToolVersions(versionFile) {
|
||||
return [((_a = match.groups) === null || _a === void 0 ? void 0 : _a.version.trim()) || ''];
|
||||
}
|
||||
}
|
||||
if (versions.length === 0) {
|
||||
core.warning(`No Python version found in ${versionFile}`);
|
||||
}
|
||||
return versions;
|
||||
core.warning(`No Python version found in ${versionFile}`);
|
||||
return [];
|
||||
}
|
||||
catch (error) {
|
||||
core.error(`Error reading ${versionFile}: ${error.message}`);
|
||||
|
||||
+2
-5
@@ -290,7 +290,6 @@ export function getVersionInputFromToolVersions(versionFile: string): string[] {
|
||||
try {
|
||||
const fileContents = fs.readFileSync(versionFile, 'utf8');
|
||||
const lines = fileContents.split('\n');
|
||||
const versions: string[] = [];
|
||||
|
||||
for (const line of lines) {
|
||||
// Skip commented lines
|
||||
@@ -303,11 +302,9 @@ export function getVersionInputFromToolVersions(versionFile: string): string[] {
|
||||
}
|
||||
}
|
||||
|
||||
if (versions.length === 0) {
|
||||
core.warning(`No Python version found in ${versionFile}`);
|
||||
}
|
||||
core.warning(`No Python version found in ${versionFile}`);
|
||||
|
||||
return versions;
|
||||
return [];
|
||||
} catch (error) {
|
||||
core.error(`Error reading ${versionFile}: ${(error as Error).message}`);
|
||||
return [];
|
||||
|
||||
Reference in New Issue
Block a user