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

Align Deno yargs_parser version with package.json version (fix .env() not working in Deno) #2306

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

forficate
Copy link

@forficate forficate commented Feb 27, 2023

Refs #2136 and https://github.com/yargs/yargs/pull/2231/files where it looks like the Deno shim got missed in the version bump.

This should allow .env() to work in Deno resolving the original #2136 bug

@forficate forficate force-pushed the fix_deno_env_vars_depdency_missmatch branch from 52c1b6b to ab2668f Compare February 27, 2023 03:42
Refs yargs#2136 and
https://github.com/yargs/yargs/pull/2231/files where it looks like the
Deno shim got missed in the version bump.

This should allow `.env()` to work in Deno resolving the original
yargs#2136 issue.
@forficate forficate force-pushed the fix_deno_env_vars_depdency_missmatch branch from ab2668f to 4d2fd30 Compare February 27, 2023 07:12
@shadowspawn
Copy link
Member

Thanks for tracking this down.

I reproduced runtime failure locally, (and after update landed as I was investigating build failure 😄 ) see it fixed with PR changes.

@forficate
Copy link
Author

Thanks for tracking this down.

I reproduced runtime failure locally, (and after update landed as I was investigating build failure 😄 ) see it fixed with PR changes.

No problem :)

@MaikuMori
Copy link

Can this be merged?

@shadowspawn
Copy link
Member

This missed the previous release but can hopefully go in the next one.

@shadowspawn
Copy link
Member

shadowspawn commented Jun 9, 2023

@MaikuMori Does this PR address yargs/yargs-parser#405? Or unrelated? (I saw your comment there.)

[Edit: fixed reference to yargs-parser issue]

@MaikuMori
Copy link

Sorry for the delay. I'm still getting:

error: Uncaught TypeError: Cannot convert undefined or null to object
            Object.keys(env).forEach(function (envVar) {
                   ^
    at Function.keys (<anonymous>)
    at applyEnvVars (https://deno.land/x/yargs_parser@v20.2.4-deno/build/lib/yargs-parser.js:661:20)
    at YargsParser.parse (https://deno.land/x/yargs_parser@v20.2.4-deno/build/lib/yargs-parser.js:356:9)
    at Function.yargsParser.detailed (https://deno.land/x/yargs_parser@v20.2.4-deno/deno.ts:32:17)
    at YargsInstance.[runYargsParserAndExecuteCommands] (https://deno.land/x/yargs@v17.7.2-deno/build/lib/yargs-factory.js:1341:86)
    at CommandInstance.parseAndUpdateUsage (https://deno.land/x/yargs@v17.7.2-deno/build/lib/command.js:163:14)
    at CommandInstance.applyBuilderUpdateUsageAndParse (https://deno.land/x/yargs@v17.7.2-deno/build/lib/command.js:150:21)
    at CommandInstance.runCommand (https://deno.land/x/yargs@v17.7.2-deno/build/lib/command.js:125:36)
    at YargsInstance.[runYargsParserAndExecuteCommands] (https://deno.land/x/yargs@v17.7.2-deno/build/lib/yargs-factory.js:1386:105)
    at YargsInstance.parse (https://deno.land/x/yargs@v17.7.2-deno/build/lib/yargs-factory.js:707:63)

Code is roughly:

await yargs(Deno.args)
  .version(false)
  .command(
    "something [a] [b]",
    "Something something",
    (yargs: YargsInstance) => {
      return yargs
        // https://github.com/yargs/yargs/pull/2306
        .env("SOMETHING")
        .positional("a", {
          type: "string",
          description: "A very A",
        })
        .positional("b", {
          type: "string",
          description: "Quite possibly B",
        })
        .option("p", {
          alias: "possibly",
          type: "number",
          description: "A possible possibility",
          default: 42,
        });
    },
    async (args: Arguments) => {
      console.log(args);
    },
  ).parseAsync();

OS: Windows

@MaikuMori
Copy link

I just noticed it hasn't been merged. I do believe it should fix the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants