Skip to content

Commit

Permalink
style: use trimEnd() instead of regexp replace (#1070)
Browse files Browse the repository at this point in the history
  • Loading branch information
antongolub authored Jan 8, 2025
1 parent d931d90 commit 4424de7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
9 changes: 3 additions & 6 deletions src/goods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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'
Expand Down Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion src/repl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
},
})
Expand Down

0 comments on commit 4424de7

Please sign in to comment.