Skip to content

Commit

Permalink
style: improve export for debug (#497)
Browse files Browse the repository at this point in the history
  • Loading branch information
Loskir authored Oct 22, 2023
1 parent 84e3ee5 commit 1c238c0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/platform.deno.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
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]";
export { debug };
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
3 changes: 1 addition & 2 deletions src/platform.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import { Agent as HttpsAgent } from "https";
import { Readable } from "stream";

// === Export debug
import { debug as d } from "debug";
export { d as debug };
export { debug } from "debug";

// === Export system-specific operations
// Turn an AsyncIterable<Uint8Array> into a stream
Expand Down

0 comments on commit 1c238c0

Please sign in to comment.