Skip to content
This repository was archived by the owner on Aug 8, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ import { changelog } from 'tanem-scripts';

### release()

Returns a `Promise` that will be resolved once the release script completes. If an error occurs during execution, the `Promise` is rejected with an `Error` object.
Returns a `Promise` that resolves with `'released'` once the release script completes, or `'nothing-to-release'` if no pull requests have merged since the last published tag. If an error occurs during execution, the `Promise` is rejected with an `Error` object.

**Example**

Expand Down
5 changes: 4 additions & 1 deletion src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ program
.description('publishes a package to npm')
.action(async () => {
try {
await release();
const result = await release();
if (result === 'nothing-to-release') {
process.stdout.write('Nothing to release\n');
}
} catch (error) {
console.error(error);
process.exit(1);
Expand Down
6 changes: 4 additions & 2 deletions src/release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { get as getData } from './data';

const execaOptions: execa.Options = { stdio: 'inherit' };

const release = async (): Promise<void> => {
const release = async (): Promise<'released' | 'nothing-to-release'> => {
const { pulls, tags } = await getData();

const latestTag = tags[tags.length - 1];
Expand All @@ -24,7 +24,7 @@ const release = async (): Promise<void> => {
: pulls;

if (pullsToRelease.length === 0) {
throw new Error('Nothing to release');
return 'nothing-to-release';
}

const labelsToRelease = [
Expand Down Expand Up @@ -101,6 +101,8 @@ const release = async (): Promise<void> => {
['publish', '--provenance', '--access', 'public'],
execaOptions,
);

return 'released';
};

export default release;
4 changes: 2 additions & 2 deletions test/release.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ describe('release validation', () => {
);
});

test('throws if nothing to release', async () => {
test("returns 'nothing-to-release' if there is nothing to release", async () => {
const mockDataNoNewPulls = {
...mockDataWithLabels,
tags: [
Expand All @@ -88,6 +88,6 @@ describe('release validation', () => {
jest
.spyOn(data, 'get')
.mockResolvedValue(mockDataNoNewPulls as unknown as data.Data);
await expect(release()).rejects.toThrow('Nothing to release');
await expect(release()).resolves.toBe('nothing-to-release');
});
});
Loading