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

feat(command): derive missing command string from module filename #527

Merged
merged 1 commit into from Jun 27, 2016

Conversation

nexdrew
Copy link
Member

@nexdrew nexdrew commented Jun 6, 2016

Mentioned in #494, this PR makes a command string optional for module-based commands, using the base filename of the require()d module for the command when the command string is not specified/exported.

Not only does this get us one step closer to implementing #492, but it also paves the way for supporting an "auto" mode for commandDir(), where conventions can be used to determine subcommand hierarchies and command names can be defined by filenames of submodules.

In this implementation, a command string is derived by filename via the following:

  • For .command(): filename is looked up in require.cache via the new which-module dependency
  • For .commandDir(): filename is already available via the require-directory API

This logic only applies when the command module does not export a command string. For non-module command objects (ones that are not require()d), a descriptive error is thrown if a command string is not given.

@coveralls
Copy link

coveralls commented Jun 6, 2016

Coverage Status

Coverage remained the same at 100.0% when pulling 363e181 on derive-command-from-filename into 365fb9a on master.

@bcoe
Copy link
Member

bcoe commented Jun 21, 2016

Looks good to me :shipit:

@bcoe bcoe merged commit 20d4b8a into master Jun 27, 2016
@bcoe bcoe deleted the derive-command-from-filename branch June 27, 2016 02:07
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

Successfully merging this pull request may close these issues.

None yet

3 participants