File tree Expand file tree Collapse file tree 1 file changed +14
-6
lines changed Expand file tree Collapse file tree 1 file changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -214,7 +214,8 @@ protected function prependRepositories(RootPackageInterface $root)
214
214
$ repoManager = $ this ->composer ->getRepositoryManager ();
215
215
$ newRepos = [];
216
216
217
- foreach ($ this ->json ['repositories ' ] as $ repoJson ) {
217
+ $ namedIndex = false ;
218
+ foreach ($ this ->json ['repositories ' ] as $ repoKey => $ repoJson ) {
218
219
if (!isset ($ repoJson ['type ' ])) {
219
220
continue ;
220
221
}
@@ -224,14 +225,21 @@ protected function prependRepositories(RootPackageInterface $root)
224
225
$ repoJson
225
226
);
226
227
$ repoManager ->prependRepository ($ repo );
227
- $ newRepos [] = $ repo ;
228
+
229
+ if (is_numeric ($ repoKey )) {
230
+ $ newRepos [] = $ repo ;
231
+ }
232
+ else {
233
+ // Indexed repository name.
234
+ $ newRepos [$ repoKey ] = $ repo ;
235
+ $ namedIndex = true ;
236
+ }
228
237
}
229
238
230
239
$ unwrapped = self ::unwrapIfNeeded ($ root , 'setRepositories ' );
231
- $ unwrapped ->setRepositories (array_merge (
232
- $ newRepos ,
233
- $ root ->getRepositories ()
234
- ));
240
+ $ repositories = $ root ->getRepositories ();
241
+ $ repositories = $ namedIndex ? ($ newRepos + $ repositories ) : array_merge ($ newRepos , $ repositories );
242
+ $ unwrapped ->setRepositories ($ repositories );
235
243
}
236
244
237
245
/**
You can’t perform that action at this time.
0 commit comments