-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Fixing git style subcommands on Windows & allowing subcommands to come from dependency modules #604
Conversation
…ncies. enables plugin infrastructure where subcommands can be separated into different modules and repos
Do we actually care that this breaks old (v<=0.0.10) versions of node? |
PING PING Are Node 0.8 and 0.6 support really required in commander.js? The only thing keeping this PR from passing all tests are engine restrictions in some dependencies. Thanks. |
Hi. Howdy. Hello there. This is a pretty popular package. Lots of PR's. Some are months old. Do people respond to them? |
@mateodelnorte Would you please resolve the conflict? |
Conflicts resolved. |
index.js
Outdated
// add executable arguments to spawn | ||
args = (process.execArgv || []).concat(args); | ||
|
||
proc = spawn('node', args, { stdio: 'inherit'}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As for 'node', can you do it like https: //github.com/tj/commander.js/blob/master/index.js#L544?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be good to go! Take a peek.
Thank you! |
Glad to help! *not sure what's up with npm 5 not installing the single find-module-bin dependency. yarn installs it just fine. |
Any timeline on when this will be published to npm? I think a simple rebuild will fix the build errors on node 8. Seemed to be a temporary problem with the registry. The dependency version def exists:
|
When is this going to be merged? The error happening in this build was a bug in npm5. |
I've fixed the merge issue that happened in package.json as a result of this not being merged since January. Looks like a re-run of the builds works completely (because it was a bug in npm5). Can we get this merged? Thx |
@abetomo Can we please slate this for merge? It's been well over a year. |
@mateodelnorte @vanesyan |
So... I updated this from upstream again. @abetomo @vanesyan Can we get this merged? |
Fix issues tj#37 - Running any subcommand throws SyntaxError on Windows
ping ping |
index.js
Outdated
@@ -544,26 +545,23 @@ Command.prototype.executeSubCommand = function(argv, args, unknown) { | |||
if (exists(localBin + '.js')) { | |||
bin = localBin + '.js'; | |||
isExplicitJS = true; | |||
} else if (exists(localBin)) { | |||
} else if (process.platform === 'win32' ? exists(localBin + '.cmd') : exists(localBin)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please put it to own variable, for readability purpose
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure thing.
@@ -5,6 +5,7 @@ | |||
var EventEmitter = require('events').EventEmitter; | |||
var spawn = require('child_process').spawn; | |||
var path = require('path'); | |||
var findModuleBin = require('find-module-bin'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please inline the module, we trying to keep commander.js dependencies-free
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a curiosity – What's the reason for wanting no dependencies?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
find-module-bin uses global-modules, to look up the appropriate os-dependent location of globally installed node modules. this won't be a simple pull-function-up refactor, as the os-specific logic is hidden in here.
perhaps we can merge this and set the refactoring as tech-debt?
personally, I think the reuse is better for the community. you don't want a massive explosion of dependencies, but having well managed dependencies can make your code more DRY and keeps the potential for the dependent packages to continue to evolve and solidify.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vanesyan
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vanesyan I don't think it makes sense to inline all of this.
This PR has been ready for merge for about a year and six months.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @vanesyan @abetomo
My team is also interested in this fix.
Is there any reason why this can not be included with the dependency?
Hello there! Sorry for make you waiting. Can you, please, resolve the comments in the review, thanks! |
Git style subcommands are still broken on Windows in master. This PR fixes them. Is there any plan to merge? Is the fact this is not merged because it's more important to have zero dependencies than to fix a glaring bug? |
@codyaverett What aspect of this Pull Request is your team interested in? |
@mateodelnorte Sorry this has been open for so long, but unfortunately I think I see why. There are some good and interesting ideas here (thanks!), but multiple potential problems from the point of view of a cautious maintainer. To be clear, I am not willing to recommend this Pull Request be accepted in its current form based on my current understanding. Some initial comments and questions, but I warn you and apologise in advance there will be more! If you don't want to invest in engaging with a new maintainer that is ok, you proposed this a long time ago. I see ideas in here I want to consider further whether or not you abandon this Pull Request. Side notes:
This is more a comment than a question or call for action. If you are addressing an issue or adding an enhancement that other people are asking for, it helps to link to the related issues. Otherwise the maintainers are judging the merit of the Pull Request just on your comments and what we recall of the issues we have seen in the past.
|
This is going to come up again with Pull Requests. My favourite two challenging images:
Commander currently has zero dependencies. That isn't a requirement, but is a simple story. It does mean every suggested dependency will be critically evaluated. And some insight into what this dependency pulls in: |
This PR was made LONG before Commander had zero dependencies. Yes, this PR 1) fixed git style subcommands on Windows and 2) introduced the ability for dependencies to supply git style subcommands. However, this was all done two years before the CONTRIBUTING guide you're proposing and I put in the effort to make PR merge-able multiple times. All well and good if you don't want to merge, but this entire process has been extremely disheartening. |
Frankly, I don't care if this code gets merged. But I would love to see the two issues be fixed. |
@shadowspawn Thank you for your time and detailed response. My motive is directly correlated with this other old issue. mateodelnorte/meta#46 I believe I can work around it, but I wasn't successful in my first attempts. I am still hopeful though. 😅 I will report future related issues in the meta project directly. Thanks! |
Thanks for info @mateodelnorte and @codyaverett Sorry you had a rough time with this one @mateodelnorte. I'm closing this Pull Request as problematic, but have noted it in #944 for future reference. (I think the next direction we want to explore with git-style commands is more control over how the commands are found. Source file naming and directory layout is one form of that, but search paths where the commands are looked for is another as in this Pull Request. i.e. installed node_modules, search path for commands like npm uses, etc.) |
This PR fixes git style subcommands to work correctly on Windows, and adds logic such that git style subcommands can be inherited from child dependencies, allowing you to break large sets of commands into a multi-repo project. (It should also allow for dynamically varying available subcommands according to what is currently installed under ./node_modules)
I built a command for managing multi-repo projects, which dogfoods this patch to manage its own repos as well: https://github.com/mateodelnorte/meta/blob/master/package.json#L38-L39. meta, itself, has only one command –
meta
, which loads all child commands by searching through it's node_modules for matchingmeta-*
modules and registering them via their index.js.This all works fine with the current
commander.js
, but when attempting to call themcommander
can't locate them. This patch ensures thatcommander
can find the git subcommands and execute them.The
git
subcommand, above, is provided by https://github.com/mateodelnorte/meta-git.The
npm
subcommand, above, is provided by https://github.com/mateodelnorte/meta-npm