Fix naming algorithm issues #347
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
#346 fixed an issue where
npmwouldn't even install. This fixes the incomplete work begun in #339, making the naming behave as I intended it to.The algorithm is similar to the last one in that it begins with the directory that the project is in. Because most directories are the same as the repo name, this is fine, I think.
From there, four values need to be generated:
The npm module name is a lowercased version of the directory without a
.jsextension. Here are a few examples:hello-there.js=>hello-therehello-there=>hello-therereact.native-thing.js=>react.native-thingWhatTheModule=>whatthemoduleThe file names follow the same algorithm as above, but with the extension. So...
hello-there.js=>hello-there.jshello-there=>hello-there.jsreact.native-thing.js=>react.native-thing.jsWhatTheModule=>whatthemodule.jsThe repo is just the dirname directly (assuming the user used the default value).
And the variable name is the module name in camel case format.
Of course, all of these can be overridden in a straightforward way. This just updates the defaults to be a bit smarter.