-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
node compat: parseArgs doesn't support default
option
#22454
Comments
I see , but there behaviour is still missing some parts: import { parseArgs } from "node:util";
const parsedArgs = parseArgs({
args: [],
options: {
handler: {
type: "string",
default: "hello",
},
},
});
console.log(parsedArgs.values.handler); Running with no arguments deno -> undefined |
I guess its just missing support for |
sigmaSd
changed the title
node compat: parseArgs behaves differently then node
node compat: parseArgs doesn't support Feb 18, 2024
default
option
The support for defaults was added in: nodejs/node#44631 |
satyarohith
pushed a commit
that referenced
this issue
Apr 11, 2024
…util.parseArgs` (#23192) Fixes #23179. Fixes #22454. Enables passing `{tokens: true}` to `parseArgs` and setting default values for options. With this PR, the observable framework works with deno out of the box (no unstable flags needed). The existing code was basically copied straight from node, so this PR mostly just updates that (out of date) vendored code. Also fixes some issues with error exports (before this PR, in certain error cases we were attempting to construct error classes that weren't actually in scope). The last change (in the second commit) adds a small hack so that we actually exercise the `test-parse-args.js` node_compat test, previously it was reported as passing though it should have failed. That test now passes. --------- Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Version: Deno 1.40.5
node a.js --args hello a
deno run a.js --args hello a
the above is already tracked by #22363
But the behavior is still not the same
Running with not arguments
deno -> undefined
nodejs -> hello
The text was updated successfully, but these errors were encountered: