Skip to content

Commit 6793871

Browse files
committed
JS: fix npmPublish skip detection that always reported "already published"
PR #7552 added an `onlyIf` block that ran `npm view @openrewrite/rewrite@<version> version` and skipped publishing if the captured output contained the version string. With `redirectErrorStream(true)`, npm's 404 error message also contains the requested version (e.g. "The requested resource '@openrewrite/rewrite@<version>' could not be found"), so the contains-check matched on every miss and silently skipped npm publish for any newly-stamped snapshot. The npm prerelease tag has been frozen at 8.82.0-20260502-150813 since then, while Maven snapshots continue to advance with the latest commit timestamp. Downstream consumers that try to spawn the JS RPC subprocess via `npx --package=@openrewrite/rewrite@<jar-version> rewrite-rpc` then fail with ETARGET because the version baked into the JAR's resource is not on npm, breaking CI in repositories like rewrite-static-analysis. Switch the check to use `npm view`'s exit code (and verify the version appears on its own line in stdout) so we only skip when the version is genuinely already published.
1 parent ec4fb3d commit 6793871

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

rewrite-javascript/build.gradle.kts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,9 +263,8 @@ val npmPublish = tasks.register<NpmTask>("npmPublish") {
263263
.directory(file("rewrite"))
264264
.redirectErrorStream(true)
265265
.start()
266-
process.waitFor()
267266
val output = process.inputStream.bufferedReader().readText().trim()
268-
val alreadyPublished = output.contains(versionToCheck)
267+
val alreadyPublished = process.waitFor() == 0 && output.lines().any { it.trim() == versionToCheck }
269268
if (alreadyPublished) {
270269
logger.lifecycle("Skipping npmPublish: @openrewrite/rewrite@$versionToCheck already published")
271270
}

0 commit comments

Comments
 (0)