You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We're using js-yaml on Yarn (our lockfiles are now regular Yaml), and to make our users' life easier we try to gracefully recover from lockfile merge conflicts (basically we parse both current and incoming versions of the lockfile, then merge them together). It turns out that in some circumstances Git will generate a bogus lockfile that duplicates some keys.
Since js-yaml doesn't support duplicated keys and aborts as soon as it sees one, we can't apply this auto-merge process when this situation happens (in our case, a valid strategy would be to simply ignore the duplicates, as they are assumed to have the same content).
While thinking about this problem I think one possible alternative would be for our project to hack our way around by using a regex to add the line number in front of each top-level key, parsing the files, then removing the number prefixes 🤔 It's sounds quite the ugly workaround though 😅
The text was updated successfully, but these errors were encountered:
I've just found this by accident going through documentation:
json (default: false) - compatibility with JSON.parse behaviour. If true, then duplicate keys in a mapping will override values rather than throwing an error.
Ref: #345 (comment)
Since js-yaml doesn't support duplicated keys and aborts as soon as it sees one, we can't apply this auto-merge process when this situation happens (in our case, a valid strategy would be to simply ignore the duplicates, as they are assumed to have the same content).
While thinking about this problem I think one possible alternative would be for our project to hack our way around by using a regex to add the line number in front of each top-level key, parsing the files, then removing the number prefixes 🤔 It's sounds quite the ugly workaround though 😅
The text was updated successfully, but these errors were encountered: