Skip to content

Commit

Permalink
refactor: use consola/utils for color utils
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Jul 17, 2023
1 parent c6fd01e commit f7a4f3b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
1 change: 0 additions & 1 deletion package.json
Expand Up @@ -27,7 +27,6 @@
},
"dependencies": {
"clipboardy": "^3.0.0",
"colorette": "^2.0.20",
"consola": "^3.2.3",
"defu": "^6.1.2",
"get-port-please": "^3.0.1",
Expand Down
4 changes: 1 addition & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions src/_utils.ts
@@ -1,6 +1,6 @@
import { promises as fs } from "node:fs";
import { networkInterfaces } from "node:os";
import { cyan, underline, bold } from "colorette";
import { colors } from "consola/utils";
import type { Certificate, HTTPSOptions } from "./types";

export async function resolveCert(
Expand Down Expand Up @@ -60,7 +60,9 @@ export function formatAddress(addr: {
}

export function formatURL(url: string) {
return cyan(
underline(decodeURI(url).replace(/:(\d+)\//g, `:${bold("$1")}/`)),
return colors.cyan(
colors.underline(
decodeURI(url).replace(/:(\d+)\//g, `:${colors.bold("$1")}/`),
),
);
}
4 changes: 2 additions & 2 deletions src/listen.ts
Expand Up @@ -9,7 +9,7 @@ import type { AddressInfo } from "node:net";
import { getPort } from "get-port-please";
import addShutdown from "http-shutdown";
import { defu } from "defu";
import { gray } from "colorette";
import { colors } from "consola/utils";
import { open } from "./lib/open";
import type { ListenOptions, Listener, ShowURLOptions } from "./types";
import {
Expand Down Expand Up @@ -103,7 +103,7 @@ export async function listen(
}

const showURL = (options?: ShowURLOptions) => {
const add = options_.clipboard ? gray("(copied to clipboard)") : "";
const add = options_.clipboard ? colors.gray("(copied to clipboard)") : "";
const lines = [];
const baseURL = options?.baseURL || options_.baseURL || "";
const name = options?.name ? ` (${options.name})` : "";
Expand Down

0 comments on commit f7a4f3b

Please sign in to comment.