mirror of
https://github.com/anomalyco/opencode.git
synced 2026-04-24 06:45:22 +00:00
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.
This commit is contained in:
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user