Skip to content

Commit

Permalink
Merge pull request #103 from ray-di/compile-check
Browse files Browse the repository at this point in the history
Check compiled
  • Loading branch information
koriym authored Mar 24, 2023
2 parents 0197688 + 08c6fab commit e0406e2
Show file tree
Hide file tree
Showing 2 changed files with 334 additions and 201 deletions.
8 changes: 8 additions & 0 deletions src/CompileInjector.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@
use function spl_autoload_register;
use function sprintf;
use function str_replace;
use function touch;

final class CompileInjector implements ScriptInjectorInterface
{
public const INSTANCE = '%s/%s.php';
public const COMPILE_CHECK = '%s/compiled';

/** @var string */
private $scriptDir;
Expand Down Expand Up @@ -157,6 +159,12 @@ private function getInstanceFile(string $dependencyIndex): string
return $file;
}

$checkFile = sprintf(self::COMPILE_CHECK, $this->scriptDir);
if (file_exists($checkFile)) {
throw new Unbound($dependencyIndex);
}

touch($checkFile);
$this->compile();
if (! file_exists($file)) {
throw new Unbound($dependencyIndex);
Expand Down
Loading

0 comments on commit e0406e2

Please sign in to comment.