(versionSpec: string)
| 113 | } |
| 114 | |
| 115 | export function parseGraalPyVersion(versionSpec: string): string { |
| 116 | const versions = versionSpec.split('-').filter(item => !!item); |
| 117 | |
| 118 | if (/^(graalpy)(.+)/.test(versions[0])) { |
| 119 | const version = versions[0].replace('graalpy', ''); |
| 120 | versions.splice(0, 1, 'graalpy', version); |
| 121 | } |
| 122 | |
| 123 | if (versions.length < 2 || versions[0] != 'graalpy') { |
| 124 | throw new Error( |
| 125 | "Invalid 'version' property for GraalPy. GraalPy version should be specified as 'graalpy<python-version>' or 'graalpy-<python-version>'. See README for examples and documentation." |
| 126 | ); |
| 127 | } |
| 128 | |
| 129 | const pythonVersion = versions[1]; |
| 130 | |
| 131 | if (!validateVersion(pythonVersion)) { |
| 132 | throw new Error( |
| 133 | "Invalid 'version' property for GraalPy. GraalPy versions should satisfy SemVer notation. See README for examples and documentation." |
| 134 | ); |
| 135 | } |
| 136 | |
| 137 | return pythonVersion; |
| 138 | } |
no test coverage detected