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

automatic argv does not work as intended from es6 #18

Closed
shadowspawn opened this issue Nov 16, 2021 · 3 comments
Closed

automatic argv does not work as intended from es6 #18

shadowspawn opened this issue Nov 16, 2021 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@shadowspawn
Copy link
Collaborator

shadowspawn commented Nov 16, 2021

argv = process.argv.slice(require.main ? 2 : 1),

I assume this line is intended to emulate the proposed process.mainArgs and get the slice right when called from the node REPL and/or with --eval.

However, when the script being executed is es6 (.mjs) then require.main is undefined and it slices incorrectly. Tested using node v16.13.0.

(I can refrain from posting bug reports if inappropriate for "early WIP"!)

@shadowspawn
Copy link
Collaborator Author

// es6.mjs
import { parseArgs } from '@pkgjs/parseargs';

const result = parseArgs();

console.log(result);
$ node es6.mjs
{
  args: {},
  values: {},
  positionals: [
    '/Users/john/Documents/Sandpits/pkgjs/parseargs-issues/play/es6.mjs'
  ]
}

@bcoe
Copy link
Collaborator

bcoe commented Dec 4, 2021

@shadowspawn this seems good to fix 👍 commented on your PR.

@shadowspawn shadowspawn self-assigned this Dec 22, 2021
@shadowspawn
Copy link
Collaborator Author

Fixed by #20

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
Development

No branches or pull requests

2 participants