(versionFile: string)
| 320 | * Python version extracted from a .tool-versions file. |
| 321 | */ |
| 322 | export function getVersionInputFromToolVersions(versionFile: string): string[] { |
| 323 | if (!fs.existsSync(versionFile)) { |
| 324 | core.warning(`File ${versionFile} does not exist.`); |
| 325 | return []; |
| 326 | } |
| 327 | |
| 328 | try { |
| 329 | const fileContents = fs.readFileSync(versionFile, 'utf8'); |
| 330 | const lines = fileContents.split('\n'); |
| 331 | |
| 332 | for (const line of lines) { |
| 333 | // Skip commented lines |
| 334 | if (line.trim().startsWith('#')) { |
| 335 | continue; |
| 336 | } |
| 337 | const match = line.match(/^\s*python\s*v?\s*(?<version>[^\s]+)\s*$/); |
| 338 | if (match) { |
| 339 | return [match.groups?.version.trim() || '']; |
| 340 | } |
| 341 | } |
| 342 | |
| 343 | core.warning(`No Python version found in ${versionFile}`); |
| 344 | |
| 345 | return []; |
| 346 | } catch (error) { |
| 347 | core.error(`Error reading ${versionFile}: ${(error as Error).message}`); |
| 348 | return []; |
| 349 | } |
| 350 | } |
| 351 | |
| 352 | /** |
| 353 | * Python version extracted from the Pipfile file. |
no outgoing calls
no test coverage detected