Skip to content

Version flag is passed as function for plugin args #1300

Closed

Description

@Grohden

Environment

npx react-native info
info Fetching system and libraries information...
System:
    OS: macOS 10.15.4
    CPU: (8) x64 Intel(R) Core(TM) i5-8257U CPU @ 1.40GHz
    Memory: 60.77 MB / 8.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 12.14.1 - ~/.nvm/versions/node/v12.14.1/bin/node
    Yarn: 1.17.3 - /Volumes/SSD/react-native-keepfy/node_modules/.bin/yarn
    npm: 6.13.4 - ~/.nvm/versions/node/v12.14.1/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.9.3 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 13.7, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
    Android SDK: Not Found
  IDEs:
    Android Studio: 4.1 AI-201.8743.12.41.6858069
    Xcode: 11.7/11E801a - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_242 - /usr/bin/javac
    Python: 2.7.16 - /usr/bin/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: 16.13.1 => 16.13.1 
    react-native: 0.63.2 => 0.63.2 
  npmGlobalPackages:
    *react-native*: Not Found

Description

The issue maybe explained better here:
Grohden/react-native-cli-bump-version#4

But to clarify, if you make a plugin that has a --version flag, this flag is now (not sure which commit/PR changed this) passed as a function

Reproducible Demo

Make a plugin with this, the version should be logging function instead of string:

module.exports = {
    commands: [{
        name: 'foo',
        func: (_, config, args) => {
            // at least when --version is not specified, I'm receiving a function here.
            console.log(args.version) // Function instead of string
        },
        options: [
            {
                name: '--version [String]',
                description: 'Foo'
            },
        ]
    }]
}

If this is not really a problem, I at least expect to be warned in the docs about this..

Activity

  1. thymikee commented on Oct 22, 2020

    @thymikee
    Member

    Does it happen when you name the arg to something different? --version is a special case for the commanderjs lib we're using for parsing arguments. And it gave us headaches as well.

  2. Grohden commented on Oct 22, 2020

    @Grohden
    ContributorAuthor

    @thymikee thx for the reply!

    Nop, I thought that it would be the case, so I've already changed the flag to semver.. so for me it's solved, but a warning in the docs would be welcome

    I could open a PR for that of you wish so... But maybe there are other reserved words that I don't know that could be documented 🤔

  3. thymikee commented on Oct 22, 2020

    @thymikee
    Member

    PR appreciated! To my knowledge --version is the only tricky one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions