Skip to content

Commit

Permalink
Make platform.deno consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
Loskir authored Oct 22, 2023
1 parent 8af26ab commit ca7d4ca
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/platform.deno.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@
export const isDeno = typeof Deno !== "undefined";

// === Export debug
import d from "https://cdn.skypack.dev/[email protected]";
export { d as debug };
import debug from "https://cdn.skypack.dev/[email protected]";
const DEBUG = "DEBUG";
if (isDeno) {
d.useColors = () => !Deno.noColor;
debug.useColors = () => !Deno.noColor;
const env = { name: "env", variable: DEBUG } as const;
const res = await Deno.permissions.query(env);
let namespace: string | undefined = undefined;
if (res.state === "granted") namespace = Deno.env.get(DEBUG);
if (namespace) d.enable(namespace);
else d.disable();
if (namespace) debug.enable(namespace);
else debug.disable();
}

// === Export system-specific operations
Expand Down

0 comments on commit ca7d4ca

Please sign in to comment.