From 1c69feecf03674bfdbd78fc8ec528733098b8765 Mon Sep 17 00:00:00 2001 From: "Fred K. Schott" Date: Sun, 4 Feb 2024 00:44:52 -0800 Subject: [PATCH] fix bug in prompt logic --- .../db/src/core/cli/commands/push/index.ts | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/packages/db/src/core/cli/commands/push/index.ts b/packages/db/src/core/cli/commands/push/index.ts index bf9649e8f7..de1880f9d5 100644 --- a/packages/db/src/core/cli/commands/push/index.ts +++ b/packages/db/src/core/cli/commands/push/index.ts @@ -97,20 +97,21 @@ async function pushSchema({ const confirmations = missingMigrationContents.reduce((acc, curr) => { return [...acc, ...(curr.confirm || [])]; }, [] as string[]); - - const response = await prompts([ - ...confirmations.map((message, index) => ({ - type: 'confirm' as const, - name: String(index), - message: red('Warning: ') + message + '\nContinue?', - initial: true, - })), - ]); - if ( - Object.values(response).length === 0 || - Object.values(response).some((value) => value === false) - ) { - process.exit(1); + if (confirmations.length > 0) { + const response = await prompts([ + ...confirmations.map((message, index) => ({ + type: 'confirm' as const, + name: String(index), + message: red('Warning: ') + message + '\nContinue?', + initial: true, + })), + ]); + if ( + Object.values(response).length === 0 || + Object.values(response).some((value) => value === false) + ) { + process.exit(1); + } } // combine all missing migrations into a single batch