Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions scripts/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,22 @@ function getNextBetaVersion() {
const nextStableVersion = `${stableVersion[0]}.${parseInt(stableVersion[1]) + 1}.0`;
const publishedVersions = getPublishedVersions(nextStableVersion, tag);
if (publishedVersions.length === 0) {
return `${nextStableVersion}-${tag}1`;
return `${nextStableVersion}-${tag}.1`;
}
const latestPublishedVersion = publishedVersions.sort((a, b) => {
const aVersion = parseInt(a.substr(a.search(/[0-9]+$/)));
const bVersion = parseInt(b.substr(b.search(/[0-9]+$/)));
return aVersion > bVersion ? -1 : 1;
})[0];
const latestTagVersion = parseInt(latestPublishedVersion.substr(latestPublishedVersion.search(/[0-9]+$/)), 10);
return `${nextStableVersion}-${tag}${latestTagVersion + 1}`;
return `${nextStableVersion}-${tag}.${latestTagVersion + 1}`;
}

function getPublishedVersions(version, tag) {
const versionsProcess = cp.spawnSync('npm', ['view', packageJson.name, 'versions', '--json']);
const versionsJson = JSON.parse(versionsProcess.stdout);
if (tag) {
return versionsJson.filter(v => !v.search(new RegExp(`${version}-${tag}[0-9]+`)));
return versionsJson.filter(v => !v.search(new RegExp(`${version}-${tag}\.[0-9]+`)));
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to merge this straight away even with the 1.1.0-beta.13 < 1.1.0-beta12 caveat, you need to add a ? here:

Suggested change
return versionsJson.filter(v => !v.search(new RegExp(`${version}-${tag}\.[0-9]+`)));
return versionsJson.filter(v => !v.search(new RegExp(`${version}-${tag}\.?[0-9]+`)));

}
return versionsJson;
}