Skip to content

Commit 0c66bf8

Browse files
committed
Publish: use tag in version
1 parent 80b1572 commit 0c66bf8

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ program.command('publish', 'Publish npm package')
4343
.option("--registry <registry>", "NPM registry to use", { required: false, validator: program.STRING })
4444
.option("--commit-hash", "Use commit hash in version (default: false)", { required: false, validator: program.BOOLEAN, default: false })
4545
.option("--tag <tag>", "NPM tag to use", { required: false, validator: program.STRING })
46+
.option("--use-tag-in-version", "Include tag in version (default: true)", { required: false, validator: program.BOOLEAN, default: true })
4647
.option("--webhook <webhook>", "Webhook URL to send notifications", { required: false, validator: program.STRING })
4748
.option("--access-token <access-token>", "NPM access token", { required: false, validator: program.STRING })
4849
.option("--dry-run", "Dry run mode, do not publish", { required: false, validator: program.BOOLEAN, default: false })
@@ -58,6 +59,7 @@ program.command('publish', 'Publish npm package')
5859
registry: registry,
5960
accessToken: options.accessToken?.toString() || null,
6061
useCommitHash: options.commitHash !== false,
62+
useTagInVersion: options.useTagInVersion !== false,
6163
dryRun: options.dryRun === true,
6264
tag: tag,
6365
webhookUrl: options.webhook?.toString() || null,

src/publish.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ export async function publish(args) {
8080
packageJson.version = packageJson.version.substring(0, dashIndex)
8181
}
8282
let nextVersion = `${packageJson.version}`;
83-
if (args.tag && args.tag !== "latest") {
83+
if (args.tag && args.tag !== "latest" && args.useTagInVersion) {
84+
logger.info(`Adding tag '${args.tag}' to version.`);
8485
nextVersion += `-${args.tag}`;
8586
}
8687
if (args.useCommitHash && shortSha) {

types/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export type PublishOptions = {
2222
accessToken: string | null | undefined;
2323
tag: string | null | undefined;
2424
useCommitHash: boolean;
25+
useTagInVersion: boolean;
2526
dryRun: boolean;
2627
webhookUrl: string | null | undefined;
2728
overrideName: string | null | undefined;

0 commit comments

Comments
 (0)