Skip to content

Commit

Permalink
Identify cli usage
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelfolaron committed Aug 29, 2024
1 parent 92d3698 commit bc041b8
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion app/Core/Bootstrap/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ class Application extends Container
*/
protected $bootedCallbacks = [];

protected $isRunningInConsole = null;

/**
* Constructor method for the class.
*
Expand Down Expand Up @@ -721,6 +723,19 @@ public function storagePath($path) {
}

public function runningInConsole() {
return defined('LEAN_CLI') && LEAN_CLI;

if ($this->isRunningInConsole === null) {

if(defined('LEAN_CLI') && LEAN_CLI) {
$this->isRunningInConsole = true;
}

if(\PHP_SAPI === 'cli' || \PHP_SAPI === 'phpdbg') {
$this->isRunningInConsole = true;
}
}

return $this->isRunningInConsole;

}
}

0 comments on commit bc041b8

Please sign in to comment.