Skip to content

Commit

Permalink
fix: do not stringify if data is already stringified
Browse files Browse the repository at this point in the history
  • Loading branch information
scarf005 committed Feb 25, 2024
1 parent e533618 commit 10b6adb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions utils/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ export const queryCli = <const Schema extends z.ZodTypeAny>(
})

export const outputTo = (timeit: Timeit) => async (data: unknown, path?: string) => {
const output = JSON.stringify(data, null, 2)
const output = typeof data === "string" ? data : JSON.stringify(data, null, 2)
if (!path) {
return console.log(output)
}
await timeit({
name: `wrote ${Array.isArray(data) ? data.length : 1} entries`,
name: `wrote ${Array.isArray(data) ? data.length : 1} entries to ${path}`,
val: Deno.writeTextFile(path, output),
})
}
Expand Down

0 comments on commit 10b6adb

Please sign in to comment.