Skip to content

Commit 20bd936

Browse files
committed
fix: use custom isEqual implementation
1 parent f8494d7 commit 20bd936

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

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

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,33 @@ const deleteAttribute = async (collection, attribute, isIndex = false) => {
712712
});
713713
}
714714

715+
const isEqual = (a, b) => {
716+
if (a === b) return true;
717+
718+
if (a && b && typeof a === 'object' && typeof b === 'object') {
719+
if (a.constructor && a.constructor.name === 'BigNumber' &&
720+
b.constructor && b.constructor.name === 'BigNumber') {
721+
return a.eq(b);
722+
}
723+
724+
if (typeof a.equals === 'function') {
725+
return a.equals(b);
726+
}
727+
728+
if (typeof a.eq === 'function') {
729+
return a.eq(b);
730+
}
731+
}
732+
733+
if (typeof a === 'number' && typeof b === 'number') {
734+
if (isNaN(a) && isNaN(b)) return true;
735+
if (!isFinite(a) && !isFinite(b)) return a === b;
736+
return Math.abs(a - b) < Number.EPSILON;
737+
}
738+
739+
return false;
740+
};
741+
715742
const compareAttribute = (remote, local, reason, key) => {
716743
if (isEmpty(remote) && isEmpty(local)) {
717744
return reason;
@@ -722,7 +749,7 @@ const compareAttribute = (remote, local, reason, key) => {
722749
const bol = reason === '' ? '' : '\n';
723750
reason += `${bol}${key} changed from ${chalk.red(remote)} to ${chalk.green(local)}`;
724751
}
725-
} else if (remote !== local) {
752+
} else if (!isEqual(remote, local)) {
726753
const bol = reason === '' ? '' : '\n';
727754
reason += `${bol}${key} changed from ${chalk.red(remote)} to ${chalk.green(local)}`;
728755
}

0 commit comments

Comments
 (0)