fix(contentful-plugin): Keep existing entry fields
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
import _ from "lodash"
|
||||
|
||||
function compareObjectsByProp(object1, object2, prop) {
|
||||
if (Array.isArray(object1[prop])) {
|
||||
object2[prop] = object2[prop].map(({ _id, ...rest }) => rest)
|
||||
return (
|
||||
_.differenceWith(object1[prop], object2[prop], _.isEqual).length === 0
|
||||
)
|
||||
} else if (typeof object1[prop] === "object") {
|
||||
delete object2[prop]._id
|
||||
return _.isEqual(object1[prop], object2[prop])
|
||||
} else {
|
||||
return object1[prop] === object2[prop]
|
||||
}
|
||||
}
|
||||
|
||||
export default compareObjectsByProp
|
||||
@@ -2,3 +2,4 @@ export { default as Validator } from "./validator"
|
||||
export { default as MedusaError } from "./errors"
|
||||
export { default as getConfigFile } from "./get-config-file"
|
||||
export { default as createRequireFromPath } from "./create-require-from-path"
|
||||
export { default as compareObjectsByProp } from "./compare-objects"
|
||||
|
||||
Reference in New Issue
Block a user