Skip to content

Commit d49593e

Browse files
committed
feat: allow desrializing args
1 parent 4faec97 commit d49593e

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"dependencies": {
3636
"citty": "^0.1.5",
3737
"consola": "^3.2.3",
38+
"destr": "^2.0.2",
3839
"magic-string": "^0.30.7",
3940
"scule": "^1.3.0",
4041
"untyped": "^1.4.2"

pnpm-lock.yaml

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/automd.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { readFile, writeFile } from "node:fs/promises";
22
import { resolve } from "node:path";
33
import { existsSync } from "node:fs";
44
import MagicString from "magic-string";
5+
import { destr } from "destr";
56
import generators from "./generators";
67
import { GenerateContext, GenerateResult } from "./generator";
78

@@ -64,9 +65,9 @@ export async function automd(_options: Partial<AutoMDOptions> = {}) {
6465
const end = start + match.groups.contents.length;
6566

6667
const args = Object.fromEntries(
67-
[...match.groups.args.matchAll(/(?<key>\w+)="(?<value>[^"]*)"/g)].map(
68-
(m) => [m.groups?.key, m.groups?.value],
69-
),
68+
[
69+
...match.groups.args.matchAll(/(?<key>\w+)=(["'])(?<value>[^\2]+?)\2/g),
70+
].map((m) => [m.groups?.key, destr(m.groups?.value)]),
7071
);
7172

7273
const generatorName = args.generator;

0 commit comments

Comments
 (0)