Skip to content

Commit

Permalink
Merge pull request #52 from embroider-build/pass-tag
Browse files Browse the repository at this point in the history
add ability to pass tag to publish command
  • Loading branch information
mansona authored Jan 26, 2024
2 parents 2565c8f + 21e40a6 commit ea1f0c3
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
22 changes: 22 additions & 0 deletions src/publish.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {},
}
`);
});
});
});
5 changes: 5 additions & 0 deletions src/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type PublishOptions = {
dryRun?: boolean;
otp?: string;
publishBranch?: string;
tag?: string;
};

async function hasCleanRepo(): Promise<boolean> {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit ea1f0c3

Please sign in to comment.