From e353b729611cf0a7110c9e176e7fd4fd35a1a614 Mon Sep 17 00:00:00 2001 From: Qu4k Date: Sun, 30 Aug 2020 15:01:36 +0200 Subject: [PATCH] fix: remove on exit --- deps.ts | 1 - examples/history.ts | 12 ++++++++++++ examples/{hello.ts => spinners.ts} | 0 mod.ts | 4 ---- 4 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 examples/history.ts rename examples/{hello.ts => spinners.ts} (100%) diff --git a/deps.ts b/deps.ts index 309ec28..77d1f1f 100644 --- a/deps.ts +++ b/deps.ts @@ -1,4 +1,3 @@ export * as colors from "https://deno.land/std@0.66.0/fmt/colors.ts"; export { encode, decode } from "https://deno.land/std@0.66.0/encoding/utf8.ts"; export * as tty from "https://deno.land/x/tty@0.1.0/mod.ts"; -export { onExit } from "https://deno.land/x/exit@0.0.1/mod.ts"; diff --git a/examples/history.ts b/examples/history.ts new file mode 100644 index 0000000..2fe053b --- /dev/null +++ b/examples/history.ts @@ -0,0 +1,12 @@ +import { wait } from "../mod.ts"; + +const spinner = wait("Loading mesozoic").start(); + +setTimeout(() => { + spinner.color = "yellow"; + spinner.text = "Loading meteorite"; +}, 1000); + +setTimeout(() => { + spinner.succeed("Started human race"); +}, 2000); diff --git a/examples/hello.ts b/examples/spinners.ts similarity index 100% rename from examples/hello.ts rename to examples/spinners.ts diff --git a/mod.ts b/mod.ts index 59a9bcb..f10c5a7 100644 --- a/mod.ts +++ b/mod.ts @@ -3,7 +3,6 @@ import { colors, encode, tty } from "./deps.ts"; import spinners from "./spinners.ts"; import { symbols } from "./log_symbols.ts"; -import { onExit } from "https://deno.land/x/exit@0.0.1/mod.ts"; type ColorFunction = (message: string) => string; const colormap: { [key: string]: ColorFunction } = { @@ -157,9 +156,6 @@ export class Spinner { if (this.#opts.hideCursor && Deno.build.os !== "windows") { tty.hideCursorSync(this.#stream); - onExit(() => { - tty.showCursorSync(this.#stream); - }); } this.render();