diff --git a/src/SparkApplication.php b/src/SparkApplication.php index 03ecdcd..d6ca5b9 100644 --- a/src/SparkApplication.php +++ b/src/SparkApplication.php @@ -15,7 +15,7 @@ class SparkApplication extends Application { public static SparkApplication $instance; - private Environment $environment; + private ?Environment $environment; private ResourceManager $resourceManager; @@ -32,20 +32,23 @@ class SparkApplication extends Application $this->pluginManager = new PluginManager(); $this->environment = Environment::createFromDirectory(null, true); - $this->environment->loadEnvironment(); + if ($this->environment) { + $this->environment->loadEnvironment(); - $this->add(new Commands\RunCommand()); - $this->add(new Commands\ResourcesCommand()); - $this->add(new Commands\ReplCommand()); - $this->add(new Commands\InitCommand()); - $this->add(new Commands\PipeCommand()); + $this->add(new Commands\RunCommand()); + $this->add(new Commands\ResourcesCommand()); + $this->add(new Commands\ReplCommand()); + $this->add(new Commands\PipeCommand()); - $this->get("list")->setHidden(true); - $this->get("completion")->setHidden(true); - $this->get("help")->setHidden(true); + $this->get("list")->setHidden(true); + $this->get("completion")->setHidden(true); + $this->get("help")->setHidden(true); - if (getenv("SPARK_PLUGINS")) { - $this->add(new Commands\PluginsCommand()); + if (getenv("SPARK_PLUGINS")) { + $this->add(new Commands\PluginsCommand()); + } + } else { + $this->add(new Commands\InitCommand()); } }