Bugfix: Crash when no env initialized

This commit is contained in:
Chris 2021-12-17 13:37:22 +01:00
parent 0f45219747
commit 8f7e8013ab

View File

@ -15,7 +15,7 @@ class SparkApplication extends Application
{ {
public static SparkApplication $instance; public static SparkApplication $instance;
private Environment $environment; private ?Environment $environment;
private ResourceManager $resourceManager; private ResourceManager $resourceManager;
@ -32,12 +32,12 @@ class SparkApplication extends Application
$this->pluginManager = new PluginManager(); $this->pluginManager = new PluginManager();
$this->environment = Environment::createFromDirectory(null, true); $this->environment = Environment::createFromDirectory(null, true);
if ($this->environment) {
$this->environment->loadEnvironment(); $this->environment->loadEnvironment();
$this->add(new Commands\RunCommand()); $this->add(new Commands\RunCommand());
$this->add(new Commands\ResourcesCommand()); $this->add(new Commands\ResourcesCommand());
$this->add(new Commands\ReplCommand()); $this->add(new Commands\ReplCommand());
$this->add(new Commands\InitCommand());
$this->add(new Commands\PipeCommand()); $this->add(new Commands\PipeCommand());
$this->get("list")->setHidden(true); $this->get("list")->setHidden(true);
@ -47,6 +47,9 @@ class SparkApplication extends Application
if (getenv("SPARK_PLUGINS")) { if (getenv("SPARK_PLUGINS")) {
$this->add(new Commands\PluginsCommand()); $this->add(new Commands\PluginsCommand());
} }
} else {
$this->add(new Commands\InitCommand());
}
} }