Skip to content

Commit c8a0982

Browse files
committed
refactor(cli): skip empties when pushing
1 parent be9a0e3 commit c8a0982

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,7 @@ const getConfirmation = async () => {
368368
return false;
369369

370370
};
371+
const isEmpty = (value) => (value === null || value === undefined || (typeof value === "string" && value.trim().length === 0) || (Array.isArray(value) && value.length === 0));
371372

372373
const approveChanges = async (resource, resourceGetFunction, keys, resourceName, resourcePlural, skipKeys = [], secondId = '', secondResourceName = '') => {
373374
log('Checking for changes ...');
@@ -390,6 +391,11 @@ const approveChanges = async (resource, resourceGetFunction, keys, resourceName,
390391
if (skipKeys.includes(key)) {
391392
continue;
392393
}
394+
395+
if (isEmpty(value) && isEmpty(localResource[key])) {
396+
continue;
397+
}
398+
393399
if (Array.isArray(value) && Array.isArray(localResource[key])) {
394400
if (JSON.stringify(value) !== JSON.stringify(localResource[key])) {
395401
changes.push({
@@ -697,6 +703,10 @@ const deleteAttribute = async (collection, attribute, isIndex = false) => {
697703
}
698704

699705
const compareAttribute = (remote, local, reason, key) => {
706+
if (isEmpty(remote) && isEmpty(local)) {
707+
return reason;
708+
}
709+
700710
if (Array.isArray(remote) && Array.isArray(local)) {
701711
if (JSON.stringify(remote) !== JSON.stringify(local)) {
702712
const bol = reason === '' ? '' : '\n';

0 commit comments

Comments
 (0)