From b51d8e885d7bb4576608caaff77e5580ccb99348 Mon Sep 17 00:00:00 2001 From: Vitaly Zakutny Date: Sun, 19 Nov 2023 21:35:06 +0300 Subject: [PATCH] chore: fix accept changes in all files flag --- src/modifiers/add.ts | 6 +++++- src/modifiers/change.ts | 7 ++++++- src/modifiers/delete.ts | 5 +++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/modifiers/add.ts b/src/modifiers/add.ts index a1479ed..cba740b 100644 --- a/src/modifiers/add.ts +++ b/src/modifiers/add.ts @@ -21,13 +21,17 @@ export function add(options: { }) { const { key, value, sort: sortDirection, accept } = options; + if (accept) { + REPLACE_ALL = true; + } + const { resources: { string } } = jsonXml; const hasKey = checkKeyExist(key, string); - if (!accept && !REPLACE_ALL && hasKey) { + if (!REPLACE_ALL && hasKey) { const answer = await hasConflict(filePath); switch (answer) { diff --git a/src/modifiers/change.ts b/src/modifiers/change.ts index 9c356dc..1d8333d 100644 --- a/src/modifiers/change.ts +++ b/src/modifiers/change.ts @@ -19,13 +19,18 @@ export function change(options: { jsonXml: XmlJson; }) { const { oldKey, newKey, sort: sortDirection, accept } = options; + + if (accept) { + REPLACE_ALL = true; + } + const { resources: { string } } = jsonXml; const hasKey = checkKeyValueExist(oldKey, string); - if (!accept && !REPLACE_ALL && hasKey) { + if (!REPLACE_ALL && hasKey) { const answer = await hasConflict(filePath); switch (answer) { diff --git a/src/modifiers/delete.ts b/src/modifiers/delete.ts index 7ce91ef..d094006 100644 --- a/src/modifiers/delete.ts +++ b/src/modifiers/delete.ts @@ -18,6 +18,11 @@ export function del(options: { jsonXml: XmlJson; }) { const { keyValue, sort: sortDirection, accept } = options; + + if (accept) { + DELETE_ALL = true; + } + const { resources: { string } } = jsonXml;