Skip to content

Commit e44eec0

Browse files
committed
feat(cli): Ask once for topics override
1 parent fdd6325 commit e44eec0

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

templates/cli/lib/commands/push.js.twig

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -915,6 +915,7 @@ const pushMessagingTopic = async ({ all, yes } = {}) => {
915915

916916
let topicsIds = [];
917917
const configTopics = localConfig.getMessagingTopics();
918+
let overrideExisting = yes;
918919

919920
if (all) {
920921
if (configTopics.length === 0) {
@@ -935,6 +936,13 @@ const pushMessagingTopic = async ({ all, yes } = {}) => {
935936
topics.push(...idTopic);
936937
}
937938

939+
if (!yes) {
940+
const answers = await inquirer.prompt(questionsPushMessagingTopics[1])
941+
if (answers.override.toLowerCase() === "yes") {
942+
overrideExisting = true;
943+
}
944+
}
945+
938946
for (let topic of topics) {
939947
log(`Pushing topic ${topic.name} ( ${topic['$id']} )`)
940948

@@ -945,12 +953,9 @@ const pushMessagingTopic = async ({ all, yes } = {}) => {
945953
})
946954
log(`Topic ${topic.name} ( ${topic['$id']} ) already exists.`);
947955

948-
if (!yes) {
949-
const answers = await inquirer.prompt(questionsPushMessagingTopics[1])
950-
if (answers.override.toLowerCase() !== "yes") {
951-
log(`Received "${answers.override}". Skipping ${topic.name} ( ${topic['$id']} )`);
952-
continue;
953-
}
956+
if (!overrideExisting) {
957+
log(`Skipping ${topic.name} ( ${topic['$id']} )`);
958+
continue;
954959
}
955960

956961
log(`Updating Topic ...`)

templates/cli/lib/questions.js.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ const questionsPushMessagingTopics = [
377377
{
378378
type: "input",
379379
name: "override",
380-
message: 'Are you sure you want to override this topic? This can lead to loss of data! Type "YES" to confirm.'
380+
message: 'What you like to override existing topics? This can lead to loss of data! Type "YES" to confirm.'
381381
}
382382
]
383383

0 commit comments

Comments
 (0)