Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve export for debug #497

Merged
merged 3 commits into from
Oct 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading