From 2cd88e40ab3feb686cc2c19855481e719ea40f4d Mon Sep 17 00:00:00 2001 From: David Edler Date: Tue, 12 Nov 2024 09:32:03 +0100 Subject: [PATCH] Dynamic page size in interactive mode Signed-off-by: David Edler --- src/lib/runLocal.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/lib/runLocal.ts b/src/lib/runLocal.ts index 25b18b1f..c2b4aa44 100644 --- a/src/lib/runLocal.ts +++ b/src/lib/runLocal.ts @@ -106,13 +106,17 @@ const chooseUpgrades = async ( ] }) + const optionsPerPage = process.stdout.rows + ? Math.max(3, process.stdout.rows - INTERACTIVE_HINT.split('\n').length - 1 - groups.length * 2) + : 50 + const response = await prompts({ choices: [...choices, { title: ' ', heading: true }], hint: INTERACTIVE_HINT, instructions: false, message: 'Choose which packages to update', name: 'value', - optionsPerPage: 50, + optionsPerPage, type: 'multiselect', onState: (state: any) => { if (state.aborted) { @@ -131,13 +135,17 @@ const chooseUpgrades = async ( selected: true, })) + const optionsPerPage = process.stdout.rows + ? Math.max(3, process.stdout.rows - INTERACTIVE_HINT.split('\n').length - 1) + : 50 + const response = await prompts({ choices: [...choices, { title: ' ', heading: true }], hint: INTERACTIVE_HINT + '\n', instructions: false, message: 'Choose which packages to update', name: 'value', - optionsPerPage: 50, + optionsPerPage, type: 'multiselect', onState: (state: any) => { if (state.aborted) {