feat: allow optional path repository
parent
3dc279cf66
commit
e5ac92b410
|
@ -930,7 +930,8 @@
|
||||||
"options": {
|
"options": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"symlink": { "type": ["boolean", "null"] }
|
"symlink": { "type": ["boolean", "null"] },
|
||||||
|
"optional": { "type": "boolean" }
|
||||||
},
|
},
|
||||||
"additionalProperties": true
|
"additionalProperties": true
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,7 +105,7 @@ class PathRepository extends ArrayRepository implements ConfigurableRepositoryIn
|
||||||
/**
|
/**
|
||||||
* Initializes path repository.
|
* Initializes path repository.
|
||||||
*
|
*
|
||||||
* @param array{url?: string, options?: array{symlink?: bool, reference?: string, relative?: bool, versions?: array<string, string>}} $repoConfig
|
* @param array{url?: string, options?: array{symlink?: bool, reference?: string, relative?: bool, versions?: array<string, string>, optional?: bool}} $repoConfig
|
||||||
*/
|
*/
|
||||||
public function __construct(array $repoConfig, IOInterface $io, Config $config, ?HttpDownloader $httpDownloader = null, ?EventDispatcher $dispatcher = null, ?ProcessExecutor $process = null)
|
public function __construct(array $repoConfig, IOInterface $io, Config $config, ?HttpDownloader $httpDownloader = null, ?EventDispatcher $dispatcher = null, ?ProcessExecutor $process = null)
|
||||||
{
|
{
|
||||||
|
@ -160,6 +160,10 @@ class PathRepository extends ArrayRepository implements ConfigurableRepositoryIn
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (array_key_exists('optional', $this->options) && $this->options['optional'] === true) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
throw new \RuntimeException('The `url` supplied for the path (' . $this->url . ') repository does not exist');
|
throw new \RuntimeException('The `url` supplied for the path (' . $this->url . ') repository does not exist');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -161,6 +161,13 @@ class PathRepositoryTest extends TestCase
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testLoadPackageFromFileSystemWithIncorrectPathButOptional(): void
|
||||||
|
{
|
||||||
|
$repositoryUrl = implode(DIRECTORY_SEPARATOR, [__DIR__, 'Fixtures', 'path', 'missing']);
|
||||||
|
$repository = $this->createPathRepo(['url' => $repositoryUrl, 'options' => ['optional' => true]]);
|
||||||
|
self::assertEmpty($repository->getPackages());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array<mixed> $options
|
* @param array<mixed> $options
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue