fix(format): handle custom formatter command property with enabled() interface
The formatter Info interface uses enabled(): Promise<string[] | false> but user configs provide a command property. Added explicit return type to the arrow function that transforms command into the enabled() return value. Also added test to verify custom formatters with command property work.pr-18308
parent
205affa0eb
commit
7a28d0520a
|
|
@ -62,7 +62,7 @@ export namespace Format {
|
|||
formatters[name] = {
|
||||
...info,
|
||||
name,
|
||||
enabled: async () => info.command,
|
||||
enabled: async (): Promise<string[] | false> => info.command,
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -55,6 +55,27 @@ describe("Format", () => {
|
|||
})
|
||||
})
|
||||
|
||||
test("status() includes custom formatters with command from config", async () => {
|
||||
await using tmp = await tmpdir({
|
||||
config: {
|
||||
formatter: {
|
||||
customtool: {
|
||||
command: ["echo", "formatted", "$FILE"],
|
||||
extensions: [".custom"],
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
await withServices(tmp.path, Format.layer, async (rt) => {
|
||||
const statuses = await rt.runPromise(Format.Service.use((s) => s.status()))
|
||||
const custom = statuses.find((s) => s.name === "customtool")
|
||||
expect(custom).toBeDefined()
|
||||
expect(custom!.extensions).toContain(".custom")
|
||||
expect(custom!.enabled).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
test("service initializes without error", async () => {
|
||||
await using tmp = await tmpdir()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue