* Parse a package specifier into name and subpath. * @param {string} specifier * @returns {{packageName: string, subpath: string}}
(specifier)
| 201 | * @returns {{packageName: string, subpath: string}} |
| 202 | */ |
| 203 | function parsePackageName(specifier) { |
| 204 | const isScoped = specifier[0] === '@'; |
| 205 | let slashIndex = StringPrototypeIndexOf(specifier, '/'); |
| 206 | |
| 207 | if (isScoped) { |
| 208 | if (slashIndex === -1) { |
| 209 | // Invalid: @scope without package name, treat whole thing as name |
| 210 | return { packageName: specifier, subpath: '.' }; |
| 211 | } |
| 212 | slashIndex = StringPrototypeIndexOf(specifier, '/', slashIndex + 1); |
| 213 | } |
| 214 | |
| 215 | if (slashIndex === -1) { |
| 216 | return { packageName: specifier, subpath: '.' }; |
| 217 | } |
| 218 | |
| 219 | return { |
| 220 | packageName: StringPrototypeSlice(specifier, 0, slashIndex), |
| 221 | subpath: '.' + StringPrototypeSlice(specifier, slashIndex), |
| 222 | }; |
| 223 | } |
| 224 | |
| 225 | /** |
| 226 | * Load and parse the package map from a config path. |
no outgoing calls
no test coverage detected
searching dependent graphs…