-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support publishing npm versions with prerelease tags
- Loading branch information
Showing
2 changed files
with
34 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const version = process.env.GIT_VERSION; | ||
|
||
if (!version) { | ||
console.error("Script expected a GIT_VERSION environment variable"); | ||
process.exit(1); | ||
} | ||
|
||
// Only allow latest tag if we are releasing a major/minor/patch | ||
if (/^\d+\.\d+\.\d+$/.test(version)) { | ||
console.log("latest"); | ||
process.exit(0); | ||
} | ||
|
||
// Use the suffix as the tag. i.e. `0.11.0-rc5` -> `rc` | ||
const suffix = version.match(/^\d+\.\d+\.\d+-([a-z]+)/i)?.[1]; | ||
if (suffix) { | ||
console.log(suffix.toLowerCase()); | ||
process.exit(0); | ||
} | ||
|
||
// Fall back to an unknown tag for safety | ||
console.log("unknown"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters