Skip to content

Commit

Permalink
Fix broken revert code after publish failure
Browse files Browse the repository at this point in the history
  • Loading branch information
mifi authored and sindresorhus committed Dec 9, 2023
1 parent d49dd4f commit 819ed29
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion source/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,14 @@ const np = async (input = 'patch', options, {pkg, rootDir, isYarnBerry}) => {
const latestTag = await git.latestTag();
const versionInLatestTag = latestTag.slice(tagVersionPrefix.length);

async function getPkgVersion() {
const pkg = await util.readPkg(rootDir);
return pkg.version;
}

try {
// Verify that the package's version has been bumped before deleting the last tag and commit.
if (versionInLatestTag === util.readPkg(rootDir).version && versionInLatestTag !== pkg.version) {
if (versionInLatestTag === await getPkgVersion() && versionInLatestTag !== pkg.version) {
await git.deleteTag(latestTag);
await git.removeLastCommit();
}
Expand Down

0 comments on commit 819ed29

Please sign in to comment.