Skip to content

Commit

Permalink
chore: fix accept changes in all files flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Pisyukaev committed Nov 19, 2023
1 parent 9c323df commit b51d8e8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/modifiers/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
7 changes: 6 additions & 1 deletion src/modifiers/change.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
5 changes: 5 additions & 0 deletions src/modifiers/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit b51d8e8

Please sign in to comment.