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

Executing np --version tries to execute typical np executiion #602

Closed
mikeerickson opened this issue Feb 13, 2021 · 8 comments
Closed

Executing np --version tries to execute typical np executiion #602

mikeerickson opened this issue Feb 13, 2021 · 8 comments

Comments

@mikeerickson
Copy link
Sponsor

Description

When executing np --version, it seems np is trying to actually run within current directory

The following example executes np --version in a directory which does not have .git initialized, when executing in a typical npm project, it has a different message

Steps to reproduce

  1. In any directory, use np --version

Expected behavior

Show the current np version information

Environment

np - 7.3.0 (trying to upgrade to 7.4.0)
Node.js - 14.5.0
npm - 7.0.15
Git - 2.30.0
OS - macOS 10.15.7

$ np --version        

✖ Could not infer the default Git branch. Please specify one with the --branch flag or with a np config.

or, from within a project which has a valid .git project

$ np --version      

Publish a new version of @codedungeon/gunner (current: 0.21.1)

? No commits found since previous release, continue? (y/N) 
@sindresorhus
Copy link
Owner

I couldn't reproduce this with either np 7.3.0 or 7.4.0.

@mikeerickson
Copy link
Sponsor Author

@sindresorhus After some digging around, I realized I had an alias for np

alias np="np --no-cleanup"

So, in affect, this is the actual call (which still has the same issue)

$ np --no-cleanup --version

✖ Could not infer the default Git branch. Please specify one with the --branch flag or with a np config.

@dopecodez
Copy link
Collaborator

Closing this as its unrelated to np.

@mikeerickson
Copy link
Sponsor Author

@dopecodez but it is related to np.

If you call np —no-cleanup —version it still has the issue.

My thinking, any call that has —version should still display version information.

@sindresorhus
Copy link
Owner

This is an intentional feature in meow: sindresorhus/meow#113

It's to make it possible for the auto-help thing to work in CLIs based on meow that have subcommand.

One way we could solve this is to allow --version, but only if there are no positional arguments. So np --yolo --version would be allowed, but np 1.2.3 --version would not. Still not sure it's worth it though.

@sindresorhus sindresorhus reopened this Feb 17, 2021
@dopecodez
Copy link
Collaborator

cool, now that i check npm it does seem to use the --version even when we use it in combination with other commands.

I agree with how meow has implemented this. So, having no support for positional arguments would make this feature tough to implement.

@mikeerickson
Copy link
Sponsor Author

I agree with @sindresorhus probably not worth the hassle. It is a rare occurrence when someone would create an alias as I have done, and had it not existed this edge case would not have been found.

Perhaps it would be a “feature” to meow in the future, but small use case at this point.

Thank you for your feedback gentleman

@sindresorhus
Copy link
Owner

Perhaps it would be a “feature” to meow in the future, but small use case at this point.

Feel free to open an issue on the meow repo.

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

No branches or pull requests

3 participants