UNPKG

@constructor-io/constructorio-connect-cli

Version:

CLI tool to enable users to interface with the Constructor Connect Ecosystem

43 lines (42 loc) 1.59 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.shouldUpdateConnectionList = shouldUpdateConnectionList; /** * Checks if the connections in the config file are updated * @param oldConnections * @param newConnections * @returns true if the two connections are equal (ie: connections in the config file are updated) */ function shouldUpdateConnectionList(oldConnections, newConnections) { const oldConnectionNames = Object.keys(oldConnections); const newConnectionNames = Object.keys(newConnections); if (oldConnectionNames.length !== newConnectionNames.length) { return true; } for (const name of oldConnectionNames) { if (!newConnections[name]) { return true; } if (!areConnectionPropertiesEqual(oldConnections, newConnections, name) || !areConnectionPropertiesEqual(newConnections, oldConnections, name)) { return true; } } return false; } /** * Checks if the properties of connection A are present in connection B and whether they have the same values * @param connectionsA * @param connectionsB * @param connectionName * @returns true if the properties of connection A are present in connection B and have the same values */ function areConnectionPropertiesEqual(connectionsA, connectionsB, connectionName) { for (const property in connectionsA[connectionName]) { if (connectionsA[connectionName][property] !== connectionsB[connectionName][property]) { return false; } } return true; }