Commit 4424de7

Anton Golub <antongolub@antongolub.com>
2025-01-08 12:59:43
style: use `trimEnd()` instead of regexp replace (#1070)
1 parent d931d90
Changed files (2)
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(
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 })
     },
   })