diff --git a/src/cli.ts b/src/cli.ts index 033d4a8..f6bf4e1 100755 --- a/src/cli.ts +++ b/src/cli.ts @@ -54,6 +54,10 @@ yargs(process.argv.slice(2)) type: 'string', description: '(pnpm) optionally pass on the --publish-branch if you need to publish from a branch other than main|master', + }) + .option('tag', { + type: 'string', + description: 'pass --tag to npm publish command', }), async function (opts) { await publish(opts); diff --git a/src/publish.test.ts b/src/publish.test.ts index 784c8b7..6144631 100644 --- a/src/publish.test.ts +++ b/src/publish.test.ts @@ -69,5 +69,27 @@ describe('publish', function () { } `); }); + + it('adds tag if passed by options', async function () { + const thingy = await npmPublish( + new Map([['thingy', { oldVersion: '3' }]]) as Solution, + reporter, + { + tag: 'best-tag', + }, + 'face', + ); + + expect(thingy).toMatchInlineSnapshot(` + { + "args": [ + "publish", + "--access=public", + "--tag=best-tag", + ], + "released": Map {}, + } + `); + }); }); }); diff --git a/src/publish.ts b/src/publish.ts index ab66d1a..e3badf2 100644 --- a/src/publish.ts +++ b/src/publish.ts @@ -15,6 +15,7 @@ type PublishOptions = { dryRun?: boolean; otp?: string; publishBranch?: string; + tag?: string; }; async function hasCleanRepo(): Promise { @@ -239,6 +240,10 @@ export async function npmPublish( args.push(`--publish-branch=${options.publishBranch}`); } + if (options.tag) { + args.push(`--tag=${options.tag}`); + } + const released = new Map(); for (const [pkgName, entry] of solution) {