Skip to content

Commit

Permalink
throw errors
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitry-shibanov committed Feb 21, 2022
1 parent 68a8d26 commit 13b497a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
13 changes: 10 additions & 3 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6089,15 +6089,22 @@ exports.getVersionsDist = getVersionsDist;
// 1.10beta1 => 1.10.0-beta1, 1.10rc1 => 1.10.0-rc1
// 1.8.5beta1 => 1.8.5-beta1, 1.8.5rc1 => 1.8.5-rc1
function makeSemver(version) {
var _a;
version = version.replace('go', '');
version = version.replace('beta', '-beta.').replace('rc', '-rc.');
let parts = version.split('-');
let semVersion = semver.coerce(version).version;
let semVersion = (_a = semver.coerce(version)) === null || _a === void 0 ? void 0 : _a.version;
if (!semVersion) {
throw new Error(`The version: ${version} can't be changed to SemVer notation`);
}
if (!parts[1]) {
return semVersion;
}
semVersion = new semver.SemVer(`${semVersion}-${parts[1]}`).version;
return semVersion;
const fullVersion = semver.valid(`${semVersion}-${parts[1]}`);
if (!fullVersion) {
throw new Error(`The version: ${version} can't be changed to SemVer notation`);
}
return fullVersion;
}
exports.makeSemver = makeSemver;
//# sourceMappingURL=installer.js.map
Expand Down
19 changes: 16 additions & 3 deletions src/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,10 +278,23 @@ export function makeSemver(version: string): string {
version = version.replace('beta', '-beta.').replace('rc', '-rc.');
let parts = version.split('-');

let semVersion = semver.coerce(version)!.version;
let semVersion = semver.coerce(version)?.version;
if (!semVersion) {
throw new Error(
`The version: ${version} can't be changed to SemVer notation`
);
}

if (!parts[1]) {
return semVersion;
}
semVersion = new semver.SemVer(`${semVersion}-${parts[1]}`).version;
return semVersion;

const fullVersion = semver.valid(`${semVersion}-${parts[1]}`);

if (!fullVersion) {
throw new Error(
`The version: ${version} can't be changed to SemVer notation`
);
}
return fullVersion;
}

0 comments on commit 13b497a

Please sign in to comment.