Skip to content

Commit

Permalink
chore(typings): Fix typings for noColor check
Browse files Browse the repository at this point in the history
  • Loading branch information
angelnext committed Mar 5, 2024
1 parent eddf8c6 commit e23a412
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@rubiks/rubiks",
"version": "1.2.1",
"version": "1.2.2",
"exports": "./mod.ts"
}
16 changes: 13 additions & 3 deletions rubiks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,21 @@ import {
} from "./levels.ts";
import { type Modifier } from "./modifiers.ts";

export interface Rubiks {
format: string;
level: string;
}

interface Global {
process?: { env: Record<string, string | undefined> }
Deno?: { noColor: boolean }
}

/**
* Class that represents a rubiks logger, each instance has it's own settings and data.
* @class
*/
export class Rubiks {
export class Rubiks implements Rubiks {
/** The format string that will end up being used for logging. */
format: string = "%s";

Expand Down Expand Up @@ -42,8 +52,8 @@ export class Rubiks {
}

constructor() {
const nc: string | undefined = globalThis.process?.env?.NO_COLOR;
if ((nc === undefined || nc === "") && !globalThis.Deno?.noColor) return;
const nc = (globalThis as Global).process?.env?.NO_COLOR;
if ((nc === undefined || nc === "") && !(globalThis as Global).Deno?.noColor) return;
this.noColor = true;
}

Expand Down
3 changes: 3 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"lib": [
"ESNext"
],
"noEmit": true,
"allowJs": true,
"checkJs": true,
Expand Down

0 comments on commit e23a412

Please sign in to comment.