| 26 | } |
| 27 | |
| 28 | func ParseNodeModuleFromPath(resolved string, isFolder bool) string { |
| 29 | path := tspath.NormalizePath(resolved) |
| 30 | idx := strings.LastIndex(path, "/node_modules/") |
| 31 | if idx == -1 { |
| 32 | return "" |
| 33 | } |
| 34 | |
| 35 | indexAfterNodeModules := idx + len("/node_modules/") |
| 36 | indexAfterPackageName := moveToNextDirectorySeparatorIfAvailable(path, indexAfterNodeModules, isFolder) |
| 37 | if path[indexAfterNodeModules] == '@' { |
| 38 | indexAfterPackageName = moveToNextDirectorySeparatorIfAvailable(path, indexAfterPackageName, isFolder) |
| 39 | } |
| 40 | return path[:indexAfterPackageName] |
| 41 | } |
| 42 | |
| 43 | func ParsePackageName(moduleName string) (packageName, rest string) { |
| 44 | idx := strings.Index(moduleName, "/") |