helapkg / hela

:icecream: Powerful software development experience and management. Enhancing @tc39 JS, @denoland and @nodejs, because we need a bit of magic. :sparkles: You can think of it as Cargo for the JavaScript ecosystem.
Mozilla Public License 2.0
331 stars 41 forks source link

bug in parse() #229

Closed tunnckoCore closed 2 years ago

tunnckoCore commented 4 years ago

update .parse method to

    const helaArgv = this.result.helaSettings.argv
    const argz = this.settings.singleMode ? helaArgv._ : helaArgv._.slice(1)
    this.result.helaSettings.argv._ = argz

(remove the first argument if not in single mode)

Currently it is causing toFlags to stringify the argv._ which includes the "current command" and this makes problems.

For example, when running hela build the argv (first argument) that is passed to the .action has argv._ === ['build'], with above update it will be empty array. For getting args, flags, argv and etc, you can access the bigger picture from the second passed argument, which looks like the following

{
    commandName: 'build',
    parsedArgv: { _: [Array] },
    rawArgs: [ 'build' ],
    flags: {
      _: [],
      cwd: '/home/charlike/github/tunnckoCore/opensource',
      showStack: false,
      verbose: false
    },
    helaSettings: {
      cwd: '/home/charlike/github/tunnckoCore/opensource',
      version: '3.0.0',
      singleMode: false,
      allowUnknownFlags: true,
      defaultsToHelp: true,
      argv: [Object]
    },
    args: [],
    command: {
      commandName: 'build',
      rawName: 'build',
      description: 'Build output files, using Babel',
      config: [Object],
      args: [],
      flags: [Map],
      examples: [],
      aliases: [Array],
      handler: [Function],
      hasRequired: [],
      hasMultiple: []
    }
  }
tunnckoCore commented 2 years ago

not relevant anymore. i guess that was before i implemented yaro, latest is on tunnckocore/opensource.