| 148 | } |
| 149 | |
| 150 | func (m *Manager) list(includeMetadata bool) ([]*Extension, error) { |
| 151 | dir := m.installDir() |
| 152 | entries, err := os.ReadDir(dir) |
| 153 | if err != nil { |
| 154 | return nil, err |
| 155 | } |
| 156 | |
| 157 | results := make([]*Extension, 0, len(entries)) |
| 158 | for _, f := range entries { |
| 159 | if !strings.HasPrefix(f.Name(), "gh-") { |
| 160 | continue |
| 161 | } |
| 162 | if f.IsDir() { |
| 163 | if _, err := os.Stat(filepath.Join(dir, f.Name(), manifestName)); err == nil { |
| 164 | results = append(results, &Extension{ |
| 165 | path: filepath.Join(dir, f.Name(), f.Name()), |
| 166 | kind: BinaryKind, |
| 167 | httpClient: m.client, |
| 168 | }) |
| 169 | } else { |
| 170 | results = append(results, &Extension{ |
| 171 | path: filepath.Join(dir, f.Name(), f.Name()), |
| 172 | kind: GitKind, |
| 173 | gitClient: m.gitClient.ForRepo(filepath.Join(dir, f.Name())), |
| 174 | }) |
| 175 | } |
| 176 | } else if isSymlink(f.Type()) { |
| 177 | results = append(results, &Extension{ |
| 178 | path: filepath.Join(dir, f.Name(), f.Name()), |
| 179 | kind: LocalKind, |
| 180 | }) |
| 181 | } else { |
| 182 | // the contents of a regular file point to a local extension on disk |
| 183 | p, err := readPathFromFile(filepath.Join(dir, f.Name())) |
| 184 | if err != nil { |
| 185 | return nil, err |
| 186 | } |
| 187 | results = append(results, &Extension{ |
| 188 | path: filepath.Join(p, f.Name()), |
| 189 | kind: LocalKind, |
| 190 | }) |
| 191 | } |
| 192 | } |
| 193 | |
| 194 | if includeMetadata { |
| 195 | m.populateLatestVersions(results) |
| 196 | } |
| 197 | |
| 198 | return results, nil |
| 199 | } |
| 200 | |
| 201 | func (m *Manager) populateLatestVersions(exts []*Extension) { |
| 202 | var wg sync.WaitGroup |