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

Fixing git style subcommands on Windows & allowing subcommands to come from dependency modules #604

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 11 additions & 12 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Copy link
Collaborator

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

Copy link
Author

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?

Copy link
Author

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vanesyan

Copy link
Author

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.

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?

var dirname = path.dirname;
var basename = path.basename;
var fs = require('fs');
Expand Down Expand Up @@ -541,29 +542,27 @@ Command.prototype.executeSubCommand = function(argv, args, unknown) {

// whether bin file is a js script with explicit `.js` extension
var isExplicitJS = false;
var isWindows = process.platform === 'win32';
if (exists(localBin + '.js')) {
bin = localBin + '.js';
isExplicitJS = true;
} else if (exists(localBin)) {
} else if (isWindows ? exists(localBin + '.cmd') : exists(localBin)) {
bin = localBin;
} else {
bin = findModuleBin(isWindows ? bin + '.cmd' : bin);
}

args = args.slice(1);

var proc;
if (process.platform !== 'win32') {
if (isExplicitJS) {
args.unshift(bin);
// add executable arguments to spawn
args = (process.execArgv || []).concat(args);
if (isExplicitJS) {
args.unshift(bin);
// add executable arguments to spawn
args = (process.execArgv || []).concat(args);

proc = spawn(process.argv[0], args, { stdio: 'inherit', customFds: [0, 1, 2] });
} else {
proc = spawn(bin, args, { stdio: 'inherit', customFds: [0, 1, 2] });
}
proc = spawn(process.argv[0], args, { stdio: 'inherit', customFds: [0, 1, 2] });
} else {
args.unshift(bin);
proc = spawn(process.execPath, args, { stdio: 'inherit' });
proc = spawn(bin, args, { stdio: 'inherit', customFds: [0, 1, 2] });
}

var signals = ['SIGUSR1', 'SIGUSR2', 'SIGTERM', 'SIGINT', 'SIGHUP'];
Expand Down