|
7 | 7 | use InvalidArgumentException; |
8 | 8 | use Tempest\Container\Container; |
9 | 9 | use Tempest\Container\Exceptions\ContainerException; |
| 10 | +use Tempest\Core\FrameworkKernel; |
10 | 11 | use Tempest\Core\Kernel; |
11 | | -use Tempest\Filesystem\LocalFilesystem; |
12 | 12 | use Tempest\Vite\TagsResolver\NullTagsResolver; |
13 | 13 | use Tempest\Vite\TagsResolver\TagsResolver; |
14 | 14 | use Tempest\Vite\Vite; |
15 | 15 | use Tempest\Vite\ViteConfig; |
16 | 16 |
|
| 17 | +use function Tempest\Support\Filesystem\delete_directory; |
| 18 | +use function Tempest\Support\Filesystem\ensure_directory_exists; |
| 19 | +use function Tempest\Support\Filesystem\write_file; |
| 20 | + |
17 | 21 | final class ViteTester |
18 | 22 | { |
19 | 23 | private ?string $root = null; |
@@ -126,30 +130,29 @@ public function call(callable $callback, array $files, bool $manifest = false, ? |
126 | 130 | $tagsResolver = null; |
127 | 131 | } |
128 | 132 |
|
129 | | - $filesystem = new LocalFilesystem(); |
130 | | - $filesystem->deleteDirectory($temporaryRootDirectory, recursive: true); |
131 | | - $filesystem->ensureDirectoryExists($temporaryRootDirectory); |
| 133 | + ensure_directory_exists($temporaryRootDirectory); |
132 | 134 |
|
133 | 135 | $paths = []; |
134 | 136 |
|
135 | 137 | foreach ($files as $path => $content) { |
136 | 138 | $path = "{$temporaryRootDirectory}/{$path}"; |
137 | 139 | $paths[] = $path; |
138 | | - $filesystem->ensureDirectoryExists(dirname($path)); |
139 | | - $filesystem->write($path, is_array($content) ? json_encode($content, flags: JSON_UNESCAPED_SLASHES) : $content); |
| 140 | + |
| 141 | + ensure_directory_exists(dirname($path)); |
| 142 | + write_file($path, is_array($content) ? json_encode($content, flags: JSON_UNESCAPED_SLASHES) : $content); |
140 | 143 | } |
141 | 144 |
|
142 | | - $this->container->get(Kernel::class)->root = $temporaryRootDirectory; |
| 145 | + $this->container->get(FrameworkKernel::class)->root = $temporaryRootDirectory; |
143 | 146 | $this->container->config($temporaryViteConfig); |
144 | 147 | $this->container->unregister(TagsResolver::class); |
145 | 148 | $callback(...$paths); |
146 | | - $this->container->get(Kernel::class)->root = $actualRootDirectory; |
| 149 | + $this->container->get(FrameworkKernel::class)->root = $actualRootDirectory; |
147 | 150 | $this->container->config($actualViteConfig); |
148 | 151 |
|
149 | 152 | if ($tagsResolver) { |
150 | 153 | $this->container->register(TagsResolver::class, fn () => $tagsResolver); |
151 | 154 | } |
152 | 155 |
|
153 | | - $filesystem->deleteDirectory($temporaryRootDirectory, recursive: true); |
| 156 | + delete_directory($temporaryRootDirectory); |
154 | 157 | } |
155 | 158 | } |
0 commit comments