mirror of
https://github.com/pestphp/pest.git
synced 2026-09-05 06:13:35 +02:00
feat: allow configuring the TIA directory (#1787)
* feat: allow configuring the TIA directory * refactor: simplify TIA directory resolution * fix: bootstrap TIA state after configuration * chore: apply Rector to TIA storage test * fix: stabilize checks on pull requests * fix: align TIA fixture branch resolution * fix: preserve success snapshot formatting * fix: order TIA storage snapshot * chore: keep TIA directory changes scoped
This commit is contained in:
@@ -9,8 +9,17 @@ namespace Pest\Plugins\Tia;
|
||||
*/
|
||||
final class Storage
|
||||
{
|
||||
private static ?string $directory = null;
|
||||
|
||||
public static function tempDir(string $projectRoot): string
|
||||
{
|
||||
if (self::$directory !== null) {
|
||||
$isAbsolute = str_starts_with(self::$directory, DIRECTORY_SEPARATOR)
|
||||
|| preg_match('/^[a-z]:[\\\\\/]/i', self::$directory) === 1;
|
||||
|
||||
return $isAbsolute ? self::$directory : $projectRoot.DIRECTORY_SEPARATOR.self::$directory;
|
||||
}
|
||||
|
||||
$home = self::homeDir();
|
||||
|
||||
if ($home === null) {
|
||||
@@ -25,6 +34,11 @@ final class Storage
|
||||
.DIRECTORY_SEPARATOR.self::projectKey($projectRoot);
|
||||
}
|
||||
|
||||
public static function useDirectory(?string $directory): void
|
||||
{
|
||||
self::$directory = $directory;
|
||||
}
|
||||
|
||||
public static function purge(string $projectRoot): void
|
||||
{
|
||||
$dir = self::tempDir($projectRoot);
|
||||
|
||||
Reference in New Issue
Block a user