Skip to content

Commit

Permalink
refactor: prefer std
Browse files Browse the repository at this point in the history
  • Loading branch information
kidonng committed Aug 8, 2022
1 parent b7270df commit cf813d2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ export {
UpdateNotifier,
} from "https://x.nest.land/[email protected]/mod.ts";
export * as semver from "https://deno.land/x/[email protected]/mod.ts";
export { default as stripJsonComments } from "https://esm.sh/[email protected]";
export { parse as parseJson } from "https://deno.land/[email protected]/encoding/jsonc.ts";
9 changes: 3 additions & 6 deletions src/load_config.ts
Original file line number Diff line number Diff line change
@@ -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"];
Expand Down Expand Up @@ -60,10 +60,7 @@ async function parseConfig(
async function parseDenoConfig(
configPath: string,
): Promise<ScriptsConfiguration> {
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;
}

0 comments on commit cf813d2

Please sign in to comment.