Skip to content

Commit

Permalink
Add comment explaining plural handling for defaultExportNames
Browse files Browse the repository at this point in the history
@lencioni pointed out that this was a little confusing, and I agree.
Adding a comment to explain the use-case a little should help others
reading this code.
  • Loading branch information
trotzig committed Jan 22, 2017
1 parent 12f4d7b commit 9a6dcc9
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/ModuleFinder.js
Expand Up @@ -78,6 +78,11 @@ function defaultExportNames(pathToFile) {
];

if (/e?s$/.test(dirName)) {
// When the directory has an "s" (or "es") at the end, we assume it's a
// plural form of something. We then add a third name to the list. As an
// example, if we have './mocks/ModuleFinder.js' as the pathToFile, we add
// 'mock-ModuleFinder' here, which will allow the user to find the module
// with `MockModuleFinder` as the variable name.
result.push(`${dirName.replace(/e?s$/, '')}-${fileName}`);
}
return result;
Expand Down

0 comments on commit 9a6dcc9

Please sign in to comment.