Skip to main content

extract_package_name_from_node_modules_path

Function extract_package_name_from_node_modules_path 

Source
pub fn extract_package_name_from_node_modules_path(
    path: &Path,
) -> Option<String>
Expand description

Extract npm package name from a resolved path inside node_modules.

Given a path like /project/node_modules/react/index.js, returns Some("react"). Given a path like /project/node_modules/@scope/pkg/dist/index.js, returns Some("@scope/pkg"). Returns None if the path doesn’t contain a node_modules segment.