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

Git-style sub-commands not working on Windows #890

Closed
MystK opened this issue Nov 27, 2018 · 11 comments
Closed

Git-style sub-commands not working on Windows #890

MystK opened this issue Nov 27, 2018 · 11 comments

Comments

@MystK
Copy link

MystK commented Nov 27, 2018

It looks like due to how Yarn v1.12.3/npm v6.4.1 handle bins compared to linux/mac, the sub-commands are not working.

image

index should be the bin name, but it becomes the js file name
legion is the subcommand I am trying to run
It's trying to require the file in the root directory, but it should be searching in the folder that the bin was ran.

I traced it to line 569 inside of index.js of commander.

Is anyone else getting this or is it just something stupid I am doing? If it is an issue, I would be willing to make a PR. atm, I'm not sure how I can grab the bin file name though since I can't find it anywhere I've looked, including the process.argv.

image

@erolkskn
Copy link

It's just how sub-command execution works. If you look at that line of code

var bin = basename(f, path.extname(f)) + '-' + args[0];

it concatenates current executing filename and args[0] ( sub-command ). So what you are talking about is not a bug neither feature.

@MystK
Copy link
Author

MystK commented Nov 28, 2018

@erolkskn the bug seems to be that the behavior is incorrect in windows but correct in linux.

Example:
if I run

git commit

and git actually points to /blah/index.js, on linux, it would try to call

git-commit.js

on windows, it calls

index-commit.js

On top of that, in windows, the path of where git-commit.js is seems to be incorrect.

@erolkskn
Copy link

Can you share your code with us ? If you can we can help you better, thanks.

@mizi-lin
Copy link

mizi-lin commented Feb 26, 2019

me too

git-style no support yarn global

@shadowspawn
Copy link
Collaborator

The yarn issue may have been fixed in: https://github.com/tj/commander.js/releases/tag/v2.20.0

@Mousecop
Copy link

Hello, I have updated to v2.20.0 and I am still having this problem. Is there a workaround or a resolution for this?
I am running a build command. On Linux it is expecting test-build but on Windows it is expecting index-build. Is there a way to satisfy both?
Thank you.

@shadowspawn
Copy link
Collaborator

@Mousecop Have a look at #786 where people have done some digging into the name lookup. Basically, you want to reduce the variations: try naming your entry file the same as your command.

@shadowspawn

This comment has been minimized.

@shadowspawn

This comment has been minimized.

@shadowspawn
Copy link
Collaborator

.command now supports the executableFile option (thanks to @abetomo).
Shipped in v3: https://github.com/tj/commander.js/releases/tag/v3.0.0

@shadowspawn
Copy link
Collaborator

I am closing this in favour of #714 which I think describes the same issue.
Duplicate of #714

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

5 participants