Skip to content

Commit

Permalink
feat: auto normalize key casings
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Feb 21, 2024
1 parent 96e2ade commit bc0e4d2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/_parse.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { destr } from "destr";
import { camelCase } from "scule";

export interface Block {
generator: string;
Expand Down Expand Up @@ -43,7 +44,8 @@ export function parseRawArgs(rawArgs: string) {
const args = Object.create(null);

for (const part of rawArgs.split(/\s+/)) {
const [key, value] = part.split("=");
const [_key, value] = part.split("=");
const key = _key && camelCase(_key);
if (key && value) {
args[key] = destr(value);
} else if (part.startsWith("no-")) {
Expand Down
2 changes: 1 addition & 1 deletion test/parse.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe("parseRawArgs", () => {
[`foo=bar`, { foo: "bar" }],
[
`a-key=a-value another-key=another-value`,
{ "a-key": "a-value", "another-key": "another-value" },
{ aKey: "a-value", anotherKey: "another-value" },
],
] as const;
for (const [input, expected] of tests) {
Expand Down

0 comments on commit bc0e4d2

Please sign in to comment.