Skip to content

Commit

Permalink
refactor(core): #29 use serialize-javascript to serialize json content
Browse files Browse the repository at this point in the history
  • Loading branch information
sdorra committed Jun 1, 2024
1 parent 18094b5 commit 36a51e7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 2 additions & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"@types/micromatch": "^4.0.7",
"@types/node": "^20.9.0",
"@types/pluralize": "^0.0.33",
"@types/serialize-javascript": "^5.0.4",
"@vitest/coverage-v8": "^1.5.0",
"tsup": "^8.0.2",
"tsx": "^4.1.1",
Expand All @@ -40,6 +41,7 @@
"gray-matter": "^4.0.3",
"micromatch": "^4.0.5",
"pluralize": "^8.0.0",
"serialize-javascript": "^6.0.2",
"yaml": "^2.4.1",
"zod": "^3.22.5"
}
Expand Down
5 changes: 3 additions & 2 deletions packages/core/src/serializer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import z from "zod";
import serializeJs from "serialize-javascript";

const literalSchema = z.union([
z.string(),
Expand Down Expand Up @@ -26,5 +27,5 @@ export const serializableSchema = z.record(jsonSchema);
export type Serializable = z.infer<typeof serializableSchema>;

export function serialize(value: Array<unknown>): string {
return JSON.stringify(value, null, 2);
}
return serializeJs(value, { space: 2, isJSON: true, unsafe: true });
}
10 changes: 10 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 36a51e7

Please sign in to comment.