Skip to content

Commit b8ff77c

Browse files
committed
fix(legacy-json): misc promotion logic fix
Re nodejs/node#57343 (comment) Signed-off-by: flakey5 <[email protected]>
1 parent a97df05 commit b8ff77c

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/generators/legacy-json/utils/buildSection.mjs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,11 @@ export const createSectionBuilder = () => {
116116
// Only promote certain keys
117117
if (!UNPROMOTED_KEYS.includes(key)) {
118118
// Merge the section's properties into the parent section
119-
parent[key] = parent[key]
120-
? // If the parent already has this key, concatenate the values
121-
[].concat(parent[key], value)
122-
: // Otherwise, directly assign the section's value to the parent
123-
[];
119+
if (parent[key] && Array.isArray(parent[key])) {
120+
parent[key] = parent[key].concat(value);
121+
} else {
122+
parent[key] ||= value;
123+
}
124124
}
125125
});
126126
}

0 commit comments

Comments
 (0)