Skip to content

Commit

Permalink
fix: show new version during npm publish dry run
Browse files Browse the repository at this point in the history
  • Loading branch information
balazsorban44 committed Oct 3, 2023
1 parent 17d213b commit 1f03c0d
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions packages/monorepo-release/src/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ export async function publish(packages: PackageToRelease[], options: Config) {
log.info(
`Dry run won't release \`${bold(pkg.name + "@" + pkg.newVersion)}\``,
)
} else {
log.info(
`Writing version "${bold(
pkg.newVersion,
)}" to package.json for package \`${bold(pkg.name)}\``,
)
await pkgJson.update(pkg.relativeDir, { version: pkg.newVersion })
log.info("package.json file has been written, publishing...")
}

log.debug(
`Writing version "${bold(
pkg.newVersion,
)}" to package.json for package \`${bold(pkg.name)}\``,
)
await pkgJson.update(pkg.relativeDir, { version: pkg.newVersion })
log.info("package.json file has been written, publishing.")

let npmPublish = `pnpm publish --access public --registry=https://registry.npmjs.org --no-git-checks`
if (dryRun) {
npmPublish += " --dry-run"
Expand All @@ -50,6 +50,11 @@ export async function publish(packages: PackageToRelease[], options: Config) {
}

execSync(npmPublish, { cwd: pkg.relativeDir })

if (dryRun) {
log.debug("Dry run, reverting version change.")
await pkgJson.update(pkg.relativeDir, { version: pkg.oldVersion })
}
}

if (dryRun) {
Expand Down

0 comments on commit 1f03c0d

Please sign in to comment.