Skip to content

Commit

Permalink
feat: Modernize and publish to JSR
Browse files Browse the repository at this point in the history
  • Loading branch information
eliassjogreen committed Sep 22, 2024
1 parent b5d1d5f commit 9db7c57
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ jobs:
run: deno fmt --check

- name: Run deno lint
run: deno lint --unstable
run: deno lint
23 changes: 23 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Publish
on:
workflow_dispatch:
release:
types: [published]

jobs:
publish:
runs-on: ubuntu-latest

permissions:
contents: read
id-token: write

steps:
- uses: actions/checkout@v4
- name: Install Deno
uses: denoland/setup-deno@v1
with:
deno-version: v1.x

- name: Publish package
run: deno publish
20 changes: 0 additions & 20 deletions .github/workflows/release.yml

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020-present the denosaurs team
Copyright (c) 2020-2024 the denosaurs team

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
10 changes: 10 additions & 0 deletions deno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "@denosaurs/tty",
"version": "0.2.0",
"exports": {
".": "./mod.ts"
},
"tasks": {
"update": "deno run --allow-net --allow-write update.ts"
}
}
10 changes: 5 additions & 5 deletions is_interactive.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
export async function isInteractiveAsync(
stream: { rid: number },
stream: { isTerminal(): boolean },
): Promise<boolean> {
if (await Deno.permissions.query({ name: "env" })) {
return (
Deno.isatty(stream.rid) &&
stream.isTerminal() &&
Deno.env.get("TERM") !== "dumb" &&
!Deno.env.get("CI")
);
}
return Deno.isatty(stream.rid);
return stream.isTerminal();
}

export function isInteractive(stream: { rid: number }): boolean {
return Deno.isatty(stream.rid);
export function isInteractive(stream: { isTerminal(): boolean }): boolean {
return stream.isTerminal();
}
11 changes: 6 additions & 5 deletions mod.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const mac = (await Deno.permissions.query({ name: "env" })).state === "granted"
? Deno.env.get("TERM_PROGRAM") === "Apple_Terminal"
: false;
const mac: boolean =
(await Deno.permissions.query({ name: "env" })).state === "granted"
? Deno.env.get("TERM_PROGRAM") === "Apple_Terminal"
: false;

export const ESC = "\u001B[";

Expand Down Expand Up @@ -31,8 +32,8 @@ export const PREV_LINE = "1F";
export const COLUMN = "1G"; // left?
export const HOME = "H";

export type SyncStream = Deno.WriterSync;
export type AsyncStream = Deno.Writer;
export type SyncStream = Pick<typeof Deno.stdout, "writeSync">;
export type AsyncStream = Pick<typeof Deno.stdout, "write">;

export * from "./tty_async.ts";
export * from "./tty_sync.ts";
Expand Down
2 changes: 1 addition & 1 deletion tty_async.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { encode } from "./util.ts";

import {
AsyncStream,
type AsyncStream,
CLEAR_DOWN,
CLEAR_LEFT,
CLEAR_LINE,
Expand Down
2 changes: 1 addition & 1 deletion tty_sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
SCROLL_DOWN,
SCROLL_UP,
SHOW,
SyncStream,
type SyncStream,
UP,
} from "./mod.ts";

Expand Down

0 comments on commit 9db7c57

Please sign in to comment.