-
Notifications
You must be signed in to change notification settings - Fork 4
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: return path as name for root directories #36
Conversation
module.exports = dir => dir ? getName(basename(dirname(dir)), basename(dir)) | ||
: false | ||
module.exports = (dir) => { | ||
if (!dir) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fun fact: removing ternary operators is a good way to get on my good side ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to know ;)
The package name at the root should be empty. Returning the path is incorrect. Your package name is not "/" nor is it "C:\" |
Can you show where this is blocking npm/cli#7038? That isn't apparent to me. |
Sure :). As far as my understanding goes, the The Assuming the path you are trying to run
My way to resolve the issue above was to have |
I think you're beginning to see why root packages are not allowed. Is the problem you're trying to solve so much of an issue that we have to refactor major parts of npm now? npm has never allowed root directories to be packages. Environments like docker solve this by putting things in a subdirectory first, which is pretty standard at this point. I'm hesitant to go down this path, frankly. I think this is a good restriction and keeps a lot of odd (and maybe even potentially dangerous) setups from happening. |
I agree that for macOS and Linux it wouldn't make sense to installing packages in a root directory, but in Windows (excluding the boot drive) it could make some slight sense for installing in the root directory for external drives if the only thing you want on your drive is a JS project. I could make root directory installs only allowed on Windows on drives other than C if your worry is with root directories for boot drives, but if root directory installs shouldn't be allowed regardless of what drive it is being installed in I could remove all of the changes for root installs. The current behaviour of installing packages in a root directory is throwing an error ( |
What/Why
Previously, name-from-folder would return an empty string when passing in a root directory path (Linux/macOS:
/
and Windows:{A-Z}:\
).With this PR, instead of returning an empty string, it now returns the path for the directory as the name
References
This change is required for npm/cli#7038 to work.
EDIT: Linked to npm/cli PR