Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

argv returns extraneous filename in _ key #443

Closed
brandonpittman opened this issue Jun 17, 2022 · 4 comments · May be fixed by johnperez416/zx#15 or CortezFrazierJr/zx#6
Closed

argv returns extraneous filename in _ key #443

brandonpittman opened this issue Jun 17, 2022 · 4 comments · May be fixed by johnperez416/zx#15 or CortezFrazierJr/zx#6
Labels
bug Something isn't working

Comments

@brandonpittman
Copy link

Given file: foo

#!/usr/bin/env zx

console.log(process.argv)

let name = argv._[1]

echo(`Hello, ${name}.`)

When running $ ./foo Brandon:

Expected Behavior

{ _: [ 'Brandon' ] }

Actual Behavior

{ _: [ './foo', 'Brandon' ] }

Steps to Reproduce the Problem

  1. Pass non-flag params to a zx script using argv

This seems to be happening because zx is passing an extra argument: the cli.js file.

Log just process.argv from the zx script:

[
  '/Users/blp/Library/pnpm/nodejs/16.15.1/bin/node',
  '/Users/blp/Library/pnpm/global/5/node_modules/zx/build/cli.js',
  './foo',
  'Brandon'
]

Could zx use process.argv.slice(3) when setting up minimist?

Specifications

  • Version: 7.0
  • Platform: Darwin
@antonmedv
Copy link
Collaborator

Yes, lets add more tests for this bug and fix it.

@antonmedv antonmedv added the bug Something isn't working label Jun 20, 2022
@antonmedv
Copy link
Collaborator

Fixed!

@andrioid
Copy link

andrioid commented Jul 7, 2022

How is it fixed? Was there a new release?

@antonmedv
Copy link
Collaborator

Yes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
3 participants