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

Subcommands broken if bin name is different from name of script it resolves to #830

Closed
wants to merge 2 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,16 @@ Command.prototype.executeSubCommand = function(argv, args, unknown) {
isExplicitJS = true;
} else if (exists(localBin)) {
bin = localBin;
} else if (link !== f) {
// if the resolved bin file is different, try that instead
bin = basename(link, '.js') + '-' + args[0];
localBin = path.join(baseDir, bin);
if (exists(localBin + '.js')) {
bin = localBin + '.js';
isExplicitJS = true;
} else if (exists(localBin)) {
bin = localBin;
}
}

args = args.slice(1);
Expand Down
5 changes: 5 additions & 0 deletions test/test.command.executableSubcommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,8 @@ var bin = path.join(__dirname, './fixtures/pmlink')
exec(bin + ' install', function (error, stdout, stderr) {
stdout.should.equal('install\n');
});

// pmlink-publish should fallback to pm-publish with explicit extension
exec(bin + ' publish', function (error, stdout, stderr) {
stdout.should.equal('publish\n');
});