Skip to content

Commit 63ceddb

Browse files
authored
chore: bump v to 8.1.9 (google#917)
* chore: optimize `echo` impl * chore: bump version to 8.1.9
1 parent 88a545a commit 63ceddb

File tree

3 files changed

+8
-15
lines changed

3 files changed

+8
-15
lines changed

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "zx",
3-
"version": "8.1.8",
3+
"version": "8.1.9",
44
"description": "A tool for writing better scripts",
55
"type": "module",
66
"main": "./build/index.cjs",

src/goods.ts

+5-12
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import assert from 'node:assert'
1616
import { createInterface } from 'node:readline'
1717
import { $, within, ProcessOutput } from './core.js'
18-
import { type Duration, isString, parseDuration } from './util.js'
18+
import { type Duration, isStringLiteral, parseDuration } from './util.js'
1919
import {
2020
chalk,
2121
minimist,
@@ -46,18 +46,11 @@ export async function fetch(url: RequestInfo, init?: RequestInit) {
4646

4747
export function echo(...args: any[]): void
4848
export function echo(pieces: TemplateStringsArray, ...args: any[]) {
49-
let msg
5049
const lastIdx = pieces.length - 1
51-
if (
52-
Array.isArray(pieces) &&
53-
pieces.every(isString) &&
54-
lastIdx === args.length
55-
) {
56-
msg =
57-
args.map((a, i) => pieces[i] + stringify(a)).join('') + pieces[lastIdx]
58-
} else {
59-
msg = [pieces, ...args].map(stringify).join(' ')
60-
}
50+
const msg = isStringLiteral(pieces, ...args)
51+
? args.map((a, i) => pieces[i] + stringify(a)).join('') + pieces[lastIdx]
52+
: [pieces, ...args].map(stringify).join(' ')
53+
6154
console.log(msg)
6255
}
6356

0 commit comments

Comments
 (0)