* Parse a single submodule block
(block: string)
| 70 | * Parse a single submodule block |
| 71 | */ |
| 72 | function parseSubmoduleBlock(block: string): { name: string; url: string; path: string } | null { |
| 73 | const lines = block.split('\n').map(line => line.trim()).filter(line => line) |
| 74 | let name = '' |
| 75 | let path = '' |
| 76 | let url = '' |
| 77 | |
| 78 | for (const line of lines) { |
| 79 | if (line.startsWith('"') && line.endsWith('"]')) { |
| 80 | name = line.slice(1, -2) |
| 81 | } else if (line.startsWith('path = ')) { |
| 82 | path = line.replace('path = ', '') |
| 83 | } else if (line.startsWith('url = ')) { |
| 84 | url = line.replace('url = ', '') |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | if (name && path && url) { |
| 89 | const libraryName = path.split('/').pop() || name |
| 90 | return { name: libraryName, url, path } |
| 91 | } |
| 92 | |
| 93 | return null |
| 94 | } |
| 95 | |
| 96 | /** |
| 97 | * Read README content for a library |