From 5d7192c3de635d5d6252b3e06c02bda16da09f4b Mon Sep 17 00:00:00 2001 From: btea <2356281422@qq.com> Date: Mon, 3 Feb 2025 05:02:27 +0800 Subject: [PATCH] fix: exit `approve-builds` command when `getAutomaticallyIgnoredBuilds` return empty list (#9024) * fix: exit `approve-builds` command when `getAutomaticallyIgnoredBuilds` return empty list * feat: print an info message when there are no packages to approve --------- Co-authored-by: Zoltan Kochan --- .changeset/serious-schools-perform.md | 5 +++++ exec/build-commands/src/approveBuilds.ts | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 .changeset/serious-schools-perform.md diff --git a/.changeset/serious-schools-perform.md b/.changeset/serious-schools-perform.md new file mode 100644 index 0000000000..ed72c655ab --- /dev/null +++ b/.changeset/serious-schools-perform.md @@ -0,0 +1,5 @@ +--- +"@pnpm/exec.build-commands": patch +--- + +`approve-builds` command gets the auto-ignore build list and exits early when it is an empty array [#9024](https://github.com/pnpm/pnpm/pull/9024). diff --git a/exec/build-commands/src/approveBuilds.ts b/exec/build-commands/src/approveBuilds.ts index 89a5c5430f..b2a6312175 100644 --- a/exec/build-commands/src/approveBuilds.ts +++ b/exec/build-commands/src/approveBuilds.ts @@ -1,4 +1,5 @@ import { type Config } from '@pnpm/config' +import { globalInfo } from '@pnpm/logger' import { readProjectManifest } from '@pnpm/read-project-manifest' import renderHelp from 'render-help' import { prompt } from 'enquirer' @@ -28,7 +29,10 @@ export function rcOptionsTypes (): Record { export async function handler (opts: ApproveBuildsCommandOpts & RebuildCommandOpts): Promise { if (opts.rootProjectManifest == null) return const automaticallyIgnoredBuilds = await getAutomaticallyIgnoredBuilds(opts) - if (automaticallyIgnoredBuilds == null) return + if (!automaticallyIgnoredBuilds?.length) { + globalInfo('There are no packages awaiting approval') + return + } const { result } = await prompt({ choices: sortStrings([...automaticallyIgnoredBuilds]), indicator (state: any, choice: any) { // eslint-disable-line @typescript-eslint/no-explicit-any