From cf813d2200dcd02bc664f4ded95374de06ddaf5b Mon Sep 17 00:00:00 2001 From: Kid <44045911+kidonng@users.noreply.github.com> Date: Mon, 8 Aug 2022 03:54:03 +0000 Subject: [PATCH] refactor: prefer std --- deps.ts | 2 +- src/load_config.ts | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/deps.ts b/deps.ts index c908727..a1c331d 100644 --- a/deps.ts +++ b/deps.ts @@ -29,4 +29,4 @@ export { UpdateNotifier, } from "https://x.nest.land/hatcher@0.10.2/mod.ts"; export * as semver from "https://deno.land/x/semver@v1.4.0/mod.ts"; -export { default as stripJsonComments } from "https://esm.sh/strip-json-comments@4.0.0"; +export { parse as parseJson } from "https://deno.land/std@0.151.0/encoding/jsonc.ts"; diff --git a/src/load_config.ts b/src/load_config.ts index 5268689..a70bf4d 100644 --- a/src/load_config.ts +++ b/src/load_config.ts @@ -1,4 +1,4 @@ -import { existsSync, parseYaml, path, stripJsonComments } from "../deps.ts"; +import { existsSync, parseYaml, path, parseJson } from "../deps.ts"; import { ScriptsConfiguration } from "./scripts_config.ts"; const CONFIG_FILE_NAMES = ["scripts", "velociraptor"]; @@ -60,10 +60,7 @@ async function parseConfig( async function parseDenoConfig( configPath: string, ): Promise { - let content = Deno.readTextFileSync(configPath); - if (configPath.endsWith('.jsonc')) { - content = stripJsonComments(content); - } - const { velociraptor: config = {} } = JSON.parse(content); + const content = Deno.readTextFileSync(configPath); + const { velociraptor: config = {} } = parseJson(content); return config as ScriptsConfiguration; }