zx doesn't seem to work as part of a node bin script #802
-
I'm trying to have a zx script that feels like a more traditional cli tool, meaning that it is installed to the PATH so that a user can run it by just typing {
"name": "my-cli",
"version": "0.0.1",
"bin": {
"my-cli": "./index.js"
},
"dependencies": {
"zx": "^8.0.2"
}
} And my index file is doing something very basic: #!/usr/bin/env zx
void (async function main() {
const branch = await $`git branch --show-current`;
echo(branch);
})(); From the package directory if I install this globally with
I think I've found out where it's coming from: Lines 160 to 169 in 0eb81c9
Lines 144 to 155 in 0eb81c9 One of my questions is why is it necessary to write to a new |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You can avoid bin composition inside your script. As a workaround for now: #!/usr/bin/env node
import 'zx/globals'
void (async function main() {
const branch = await $`git branch --show-current`;
echo(branch);
})(); |
Beta Was this translation helpful? Give feedback.
You can avoid bin composition inside your script. As a workaround for now: