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

Possible to specify executable for subcommands? #826

Closed
jd20 opened this issue Jul 9, 2018 · 6 comments
Closed

Possible to specify executable for subcommands? #826

jd20 opened this issue Jul 9, 2018 · 6 comments

Comments

@jd20
Copy link

jd20 commented Jul 9, 2018

I have a set of subcommands, structured like this:

cli.js
cli-search.js
cli.parse.js

And in my package.json, I have "bin": { "mytool": "bin/cli.js" }. When I run subcommands locally, using node bin/cli.js, all is fine. But when I install my project globally and try to run mytool search from the command line, it doesn't work, because it's looking for mytool-search.js.

Is it possible to override the default behavior of using argv[1]? I want to avoid having to rename everything to mytool-search.js, etc...

@jd20
Copy link
Author

jd20 commented Jul 11, 2018

Can I submit a PR for this? What would be a logical way to add this functionality to the API?

@jd20
Copy link
Author

jd20 commented Jul 23, 2018

Hi, I created #830 to provide a fix for this problem. It does the common sense thing of checking what the symlink in bin resolved to, and checking for that, if it would otherwise fail to find the subcommand's script.

@pavelloz
Copy link

I dont know if it helps, but i always define executable as relative path and it always works, ie.

{
  "mytool": "./bin/cli.js"
}

@shadowspawn
Copy link
Collaborator

shadowspawn commented Jul 21, 2019

Pull Request #999 is being considered for v3, adds option to override executable file name

@shadowspawn
Copy link
Collaborator

This issue will be resolved when v3.0.0 is released. Available now as a prerelease. See #1001

@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

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