Skip to content

Commit 10d9470

Browse files
committed
fix: only include keybindings in output when they exist
Updated generatePackageJson to conditionally add keybindings to avoid including undefined values in the generated package.json. Fixed eslint-disable comment placement.
1 parent ded7fc1 commit 10d9470

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

packages/build/src/esbuild.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,8 @@ export function generatePackageJson({
220220
contributesSchema.parse(contributes)
221221
const [from, to] = substitution
222222

223-
return {
223+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
224+
const result: Record<string, any> = {
224225
...packageJson,
225226
...overrideJson,
226227
contributes: {
@@ -229,13 +230,19 @@ export function generatePackageJson({
229230
commands: transformArray(commands, from, to, "command"),
230231
menus: transformArrayRecord<Menus>(menus, from, to, ["command", "submenu", "when"]),
231232
submenus: transformArray(submenus, from, to, "id"),
232-
keybindings: keybindings ? transformArray<Keybindings>(keybindings, from, to, "command") : undefined,
233233
configuration: {
234234
title: configuration.title,
235235
properties: transformRecord<Configuration["properties"]>(configuration.properties, from, to),
236236
},
237237
},
238238
}
239+
240+
// Only add keybindings if they exist
241+
if (keybindings) {
242+
result.contributes.keybindings = transformArray<Keybindings>(keybindings, from, to, "command")
243+
}
244+
245+
return result
239246
}
240247

241248
// eslint-disable-next-line @typescript-eslint/no-explicit-any

0 commit comments

Comments
 (0)