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

Version flag is passed as function for plugin args #1300

Closed
Grohden opened this issue Oct 22, 2020 · 3 comments · Fixed by #1301
Closed

Version flag is passed as function for plugin args #1300

Grohden opened this issue Oct 22, 2020 · 3 comments · Fixed by #1301

Comments

@Grohden
Copy link
Contributor

Grohden commented Oct 22, 2020

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..

@thymikee
Copy link
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.

@Grohden
Copy link
Contributor Author

Grohden commented Oct 22, 2020

@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 🤔

@thymikee
Copy link
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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants