Skip to content

Commit

Permalink
Fix(automatic-versioning): latest prerelease identification
Browse files Browse the repository at this point in the history
  • Loading branch information
Akalanka47000 committed Nov 22, 2023
1 parent 4a08cd6 commit c7db1a2
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions packages/automatic-versioning/src/types/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,21 @@ const runner = (name, noCommit, noCommitEdit, recursive = false, prereleaseTag,
const currentBranch = (await run("git rev-parse --abbrev-ref HEAD"))?.trim();
if (currentBranch === prereleaseBranch) {
let prerelease = false;
const currentVersion = (
await run(`npm view ${name} time`)
.then((res) => res?.split(",")?.pop()?.split(":")?.[0])
.catch(async () => (await run("npm version"))?.split(",")?.[0]?.split(":")?.[1])
)
?.replace(/[{}'']/g, "")
?.trim();
let currentVersion;
try {
const versions = await run(`npm view ${name} time`).then((res) =>
res
.replace(/{|}|,|'/g, "")
.trim()
.split("\n")
);
versions.sort(
(v1, v2) => new Date(v1.trim().split(" ")[1]).getTime() - new Date(v2.trim().split(" ")[1]).getTime()
);
currentVersion = versions.pop().split(":")?.[0].trim();
} catch (e) {
currentVersion = (await run("npm version"))?.split(",")?.[0]?.split(":")?.[1]?.replace(/'/g, "")?.trim();
}
if (currentVersion?.includes(prereleaseTag)) {
await run(
`npm --workspaces-update=false --no-git-tag-version version --allow-same-version ${currentVersion}`
Expand Down

0 comments on commit c7db1a2

Please sign in to comment.