diff --git a/lib/hubspot/hubdb/hubdb.js b/lib/hubspot/hubdb/hubdb.js index a12a947..8bbdf02 100644 --- a/lib/hubspot/hubdb/hubdb.js +++ b/lib/hubspot/hubdb/hubdb.js @@ -76,26 +76,28 @@ async function uploadHubDb (config) { const table = tables.results.find((/** @type {any} */ t) => t.name === file.label) if (table) { console.warn(`${chalk.red('[Warning]')} ${chalk.magenta(file.label)} table already exists in the selected account.`) - await confirmTableOverwrite(file.label) - const spinner = ora(overwriteMsg(file.label)).start() - try { - // get table rows from the json file - const rows = require(file.path).rows - // update table columns and options - await updateHubDbTable(accountId, table.id, file.path) - // check if remote table has rows - const remoteRows = await fetchRows(accountId, table.id) - if (remoteRows.results.length) { - // clear remote table rows if exists - await clearHubDbTableRows(accountId, table.id) + const confirm = await confirmTableOverwrite(file.label) + if (confirm) { + const spinner = ora(overwriteMsg(file.label)).start() + try { + // get table rows from the json file + const rows = require(file.path).rows + // update table columns and options + await updateHubDbTable(accountId, table.id, file.path) + // check if remote table has rows + const remoteRows = await fetchRows(accountId, table.id) + if (remoteRows.results.length) { + // clear remote table rows if exists + await clearHubDbTableRows(accountId, table.id) + } + // add new rows to the table from the json file + await addRowsToHubDbTable(accountId, table.id, rows) + spinner.succeed() + } catch (error) { + spinner.fail() + console.error(error) + process.exit(1) } - // add new rows to the table from the json file - await addRowsToHubDbTable(accountId, table.id, rows) - spinner.succeed() - } catch (error) { - spinner.fail() - console.error(error) - process.exit(1) } } else { // create and publish table if it does not exist diff --git a/lib/hubspot/hubdb/prompts.js b/lib/hubspot/hubdb/prompts.js index 882d008..8215ea9 100644 --- a/lib/hubspot/hubdb/prompts.js +++ b/lib/hubspot/hubdb/prompts.js @@ -163,9 +163,6 @@ async function confirmTableOverwrite (tableName) { } } const confirmed = await confirm(confirmOverwrite(tableName)) - if (!confirmed) { - process.exit(0) - } return confirmed }