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 <z@kochan.io>
This commit is contained in:
btea
2025-02-03 05:02:27 +08:00
committed by GitHub
parent 926542cc09
commit 5d7192c3de
2 changed files with 10 additions and 1 deletions

View File

@@ -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).

View File

@@ -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<string, unknown> {
export async function handler (opts: ApproveBuildsCommandOpts & RebuildCommandOpts): Promise<void> {
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