Skip to content
Myr

Call default subcommand when there are unknown options on command line. (#1047)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by John Gee · committed by GitHub · parent 9593656 · Browse files · 3 files+14 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • Co-authored-by: zhuqiacheng <zhuqiacheng@meizu.com>

Diff stats

3 files+14 added−4 removed

  • tests:+13 added−3 removed
  • other:+1 added−1 removed

3 files+14 added−4 removed

modified:tests/fixtures/pm-default+3 added
1#!/usr/bin/env node2console.log('default');3if (process.argv.length > 2) {4 console.log(process.argv.slice(2));5}
modified:tests/command.executableSubcommand.default.test.js+10 added-3 removed
modified:index.js+1 added-1 removed
759 unmodified lines
760 outputHelpIfNecessary(this, unknown);761762 // If there were no args and we have unknown options,763 // then they are extraneous and we need to error.764 if (unknown.length > 0) {764 if (unknown.length > 0 && !this.defaultExecutable) {765 this.unknownOption(unknown[0]);766 }767 if (this.commands.length === 0 &&768 this._args.filter(function(a) { return a.required; }).length === 0) {
656 unmodified lines