https://github.com/npm/name-from-folder
Get the package name from a folder path
https://github.com/npm/name-from-folder
npm-cli
Last synced: about 1 year ago
JSON representation
Get the package name from a folder path
- Host: GitHub
- URL: https://github.com/npm/name-from-folder
- Owner: npm
- License: other
- Created: 2020-03-29T23:28:27.000Z (about 6 years ago)
- Default Branch: main
- Last Pushed: 2025-04-10T00:44:20.000Z (about 1 year ago)
- Last Synced: 2025-04-10T01:37:18.473Z (about 1 year ago)
- Topics: npm-cli
- Language: JavaScript
- Homepage:
- Size: 136 KB
- Stars: 8
- Watchers: 7
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
- Security: SECURITY.md
Awesome Lists containing this project
README
# @npmcli/name-from-folder
Get the package name from a folder path, including the scope if the
basename of the dirname starts with `@`.
For a path like `/x/y/z/@scope/pkg` it'll return `@scope/pkg`. If the path
name is something like `/x/y/z/pkg`, then it'll return `pkg`.
## USAGE
```js
const nameFromFolder = require('@npmcli/name-from-folder')
const name = nameFromFolder('/some/folder/path')
```