From 4424de7affd1b3c2e3fd57bd8ebd91b0bb495d45 Mon Sep 17 00:00:00 2001 From: Anton Golub Date: Wed, 8 Jan 2025 14:59:43 +0300 Subject: [PATCH] style: use `trimEnd()` instead of regexp replace (#1070) --- src/goods.ts | 9 +++------ src/repl.ts | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/goods.ts b/src/goods.ts index e66cd741d2..f46bf1fd0f 100644 --- a/src/goods.ts +++ b/src/goods.ts @@ -14,7 +14,6 @@ import assert from 'node:assert' import { createInterface } from 'node:readline' -import process from 'node:process' import { $, within, ProcessOutput } from './core.js' import { type Duration, @@ -25,10 +24,10 @@ import { toCamelCase, } from './util.js' import { - minimist, - nodeFetch, type RequestInfo, type RequestInit, + nodeFetch, + minimist, } from './vendor.js' export { default as path } from 'node:path' @@ -83,9 +82,7 @@ export function echo(pieces: TemplateStringsArray, ...args: any[]) { } function stringify(arg: ProcessOutput | any) { - return arg instanceof ProcessOutput - ? arg.toString().replace(/\n$/, '') - : `${arg}` + return arg instanceof ProcessOutput ? arg.toString().trimEnd() : `${arg}` } export async function question( diff --git a/src/repl.ts b/src/repl.ts index 4487218f28..e67c9204a3 100644 --- a/src/repl.ts +++ b/src/repl.ts @@ -30,7 +30,7 @@ export async function startRepl(history = HISTORY) { preview: false, writer(output: any) { return output instanceof ProcessOutput - ? output.toString().replace(/\n$/, '') + ? output.toString().trimEnd() : inspect(output, { colors: true }) }, })