-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: remove usage of jq since it cannot parse jsonc
- Loading branch information
1 parent
d06b0cd
commit 5c19708
Showing
3 changed files
with
33 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// deno-lint-ignore-file no-console | ||
// Imports | ||
import * as JSONC from "@std/jsonc" | ||
import { parseArgs } from "@std/cli" | ||
import type { record } from "@libs/typing" | ||
|
||
// Parse arguments | ||
const { cwd, _: [keypath] } = parseArgs(Deno.args, { string: ["cwd"] }) | ||
if (cwd) { | ||
Deno.chdir(cwd) | ||
} | ||
|
||
// Resolve config path and parse JSONC | ||
let node = JSONC.parse(await Deno.readTextFile("./deno.jsonc")) as record | ||
|
||
// Resolve keypath | ||
const keys = `${keypath ?? ""}`.split(/\.(?![^\[]*\])/).filter(Boolean).map((key) => key.replace(/^\[(.*)\]$/, "$1")) | ||
for (const key of keys) { | ||
node = node?.[key] as record | ||
} | ||
console.log(node ?? "") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters