Skip to content

Commit

Permalink
Fix $NO_COLOR
Browse files Browse the repository at this point in the history
wojpawlik committed Oct 22, 2024

Verified

This commit was signed with the committer’s verified signature.
wojpawlik Wojciech Pawlik
1 parent f49376a commit 502f756
Showing 3 changed files with 29 additions and 6 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: CD

on:
pull_request:
push:
branches:
- 'main'

permissions:
contents: read
id-token: write

jobs:
jsr:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v2
- run: echo "DRY_RUN=--dry-run" >> "$GITHUB_ENV"
if: github.event_name == 'pull_request'
- run: deno lint
- run: deno publish $DRY_RUN # idempotent
8 changes: 4 additions & 4 deletions io.ts
Original file line number Diff line number Diff line change
@@ -7,9 +7,9 @@ function deno() {
Deno.permissions.querySync?.({ name: "env", variable })?.state === "prompt"
? ""
: Deno.env.get(variable) ?? "";
const noColor = Deno.noColor && !Deno.stderr.isTerminal();
const useColor = !Deno.noColor && Deno.stderr?.isTerminal() !== false;
const log = (namespace: string, message: string) => {
if (!noColor) namespace = colorNamespace(namespace);
if (useColor) namespace = colorNamespace(namespace);
if (Deno.stderr) {
Deno.stderr.writeSync(encoder.encode(`${namespace} ${message}\n`));
} else { // Deno Deploy
@@ -21,9 +21,9 @@ function deno() {
}

function node() {
const noColor = !process.stderr.isTTY && !!process.env.NO_COLOR;
const useColor = !process.env.NO_COLOR && process.stderr.isTTY;
const log = (namespace: string, message: string) => {
if (!noColor) namespace = colorNamespace(namespace);
if (useColor) namespace = colorNamespace(namespace);
process.stderr.write(`${namespace} ${message}\n`);
};
const { DEBUG = "" } = process.env;
5 changes: 3 additions & 2 deletions jsr.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "@grammyjs/debug",
"version": "0.1.0",
"exports": "./mod.ts"
"version": "0.1.2",
"exports": "./mod.ts",
"exclude": [".*/"]
}

0 comments on commit 502f756

Please sign in to comment.