Skip to content

Commit 3cc0577

Browse files
committed
build: ensure the version is always a valid npm version
1 parent 4b927a2 commit 3cc0577

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

build.gradle.kts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,12 @@ fun computeVersion(): String {
1616
versionFile.readText().trim()
1717
} else {
1818
val gitVersion: groovy.lang.Closure<String> by extra
19-
val version = gitVersion()
20-
versionFile.writeText(version)
21-
version
19+
gitVersion()
20+
.let {
21+
// Normalize the version so that is always a valid NPM version.
22+
if (it.matches("""\d+\.\d+.\d+-.*""".toRegex())) it else "0.0.1-$it"
23+
}
24+
.also { versionFile.writeText(it) }
2225
}
2326
}
2427

0 commit comments

Comments
 (0)