From 819ed291e719e46c4743a9ea76d070c60d8cce5b Mon Sep 17 00:00:00 2001 From: Mikael Finstad Date: Sat, 9 Dec 2023 14:09:02 +0800 Subject: [PATCH] Fix broken revert code after publish failure --- source/index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source/index.js b/source/index.js index 94ed1550..338dbaf3 100644 --- a/source/index.js +++ b/source/index.js @@ -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(); }