这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@jamesplease
Copy link
Member

#346 fixed an issue where npm wouldn'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:

  1. the npm module name
  2. the file names
  3. the repo name
  4. the main variable name

The npm module name is a lowercased version of the directory without a .js extension. Here are a few examples:

hello-there.js => hello-there
hello-there => hello-there
react.native-thing.js => react.native-thing
WhatTheModule => whatthemodule

The file names follow the same algorithm as above, but with the extension. So...

hello-there.js => hello-there.js
hello-there => hello-there.js
react.native-thing.js => react.native-thing.js
WhatTheModule => whatthemodule.js

The 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.

@jamesplease jamesplease force-pushed the fix-naming-algorithm-really branch from 059eefa to aac5c4f Compare May 14, 2016 05:57
@jamesplease jamesplease merged commit 8632e2c into master May 14, 2016
@jamesplease jamesplease deleted the fix-naming-algorithm-really branch May 14, 2016 06:01
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.

2 participants