Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Bug]: sync field is undefined for custom preset create by $({}) #1376

@rickliujh

Description

@rickliujh

What happened?

sync field is undefined for custom preset create by $({}), $$.sync`pwd` throws an exception TypeError: $$.sync is not a function.

Using the example from the document https://google.github.io/zx/api

file test.mjs

const $$ = $({
  verbose: false,
  env: {NODE_ENV: 'production'},
})

// inspect what is in sync
console.log("$.sync ", $.sync)
console.log("$$.sync ", $$.sync)

const env = await $$`node -e 'console.log(process.env.NODE_ENV)'`
const pwd = $$.sync`pwd` // this line throws an exception TypeError: $$.sync is not a function
const hello = $({quiet: true})`echo "Hello!"`

result

$ yarn exec zx test.mjs
$.sync  [Function (anonymous)]
$$.sync  undefined
TypeError: $$.sync is not a function
    at file:///root/workspace/tmp/zx-test/test.mjs:9:20
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)

How it should work?

Line: const pwd = $$.syncpwd Shouldn't throw an TypeError: $$.sync is not a function

How to reproduce the bug?

See What happened

Version

8.8.5

What's OS kind?

Linux

What JS runtime is used?

Node.js

Runtime Version

v24.3.0 and v25.2.1

Error stack / relevant log output

$ yarn exec zx test.mjs
TypeError: $$.sync is not a function
    at file:///root/workspace/tmp/zx-test/test.mjs:9:20
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions