Commit 63ceddb

Anton Golub <antongolub@antongolub.com>
2024-10-05 11:33:48
chore: bump v to 8.1.9 (#917)
* chore: optimize `echo` impl * chore: bump version to 8.1.9
1 parent 88a545a
src/goods.ts
@@ -15,7 +15,7 @@
 import assert from 'node:assert'
 import { createInterface } from 'node:readline'
 import { $, within, ProcessOutput } from './core.js'
-import { type Duration, isString, parseDuration } from './util.js'
+import { type Duration, isStringLiteral, parseDuration } from './util.js'
 import {
   chalk,
   minimist,
@@ -46,18 +46,11 @@ export async function fetch(url: RequestInfo, init?: RequestInit) {
 
 export function echo(...args: any[]): void
 export function echo(pieces: TemplateStringsArray, ...args: any[]) {
-  let msg
   const lastIdx = pieces.length - 1
-  if (
-    Array.isArray(pieces) &&
-    pieces.every(isString) &&
-    lastIdx === args.length
-  ) {
-    msg =
-      args.map((a, i) => pieces[i] + stringify(a)).join('') + pieces[lastIdx]
-  } else {
-    msg = [pieces, ...args].map(stringify).join(' ')
-  }
+  const msg = isStringLiteral(pieces, ...args)
+    ? args.map((a, i) => pieces[i] + stringify(a)).join('') + pieces[lastIdx]
+    : [pieces, ...args].map(stringify).join(' ')
+
   console.log(msg)
 }
 
package-lock.json
@@ -1,12 +1,12 @@
 {
   "name": "zx",
-  "version": "8.1.8",
+  "version": "8.1.9",
   "lockfileVersion": 3,
   "requires": true,
   "packages": {
     "": {
       "name": "zx",
-      "version": "8.1.8",
+      "version": "8.1.9",
       "license": "Apache-2.0",
       "bin": {
         "zx": "build/cli.js"
package.json
@@ -1,6 +1,6 @@
 {
   "name": "zx",
-  "version": "8.1.8",
+  "version": "8.1.9",
   "description": "A tool for writing better scripts",
   "type": "module",
   "main": "./build/index.cjs",