Bläddra i källkod

prevent pc config override (#1130)

Sheldon 2 år sedan
förälder
incheckning
62785fc358
2 ändrade filer med 8 tillägg och 7 borttagningar
  1. 7 6
      pynecone/config.py
  2. 1 1
      pynecone/constants.py

+ 7 - 6
pynecone/config.py

@@ -218,12 +218,13 @@ class Config(Base):
                 continue
             os.environ[key] = str(value)
 
-        # Load env variables from env file
-        load_dotenv(self.env_path, override=self.override_os_envs)  # type: ignore
-        # Recompute constants after loading env variables
-        importlib.reload(constants)
-        # Recompute instance attributes
-        self.recompute_field_values()
+        # Avoid overriding if env_path is not provided or does not exist
+        if self.env_path is not None and os.path.isfile(self.env_path):
+            load_dotenv(self.env_path, override=self.override_os_envs)  # type: ignore
+            # Recompute constants after loading env variables
+            importlib.reload(constants)
+            # Recompute instance attributes
+            self.recompute_field_values()
 
     def recompute_field_values(self):
         """Recompute instance field values to reflect new values after reloading

+ 1 - 1
pynecone/constants.py

@@ -100,7 +100,7 @@ DEPLOY_URL = get_value("DEPLOY_URL")
 # bun root location
 BUN_ROOT_PATH = "$HOME/.bun"
 # The default path where bun is installed.
-BUN_PATH = f"{BUN_ROOT_PATH}/bin/bun"
+BUN_PATH = get_value("BUN_PATH", f"{BUN_ROOT_PATH}/bin/bun")
 # Command to install bun.
 INSTALL_BUN = f"curl -fsSL https://bun.sh/install | bash -s -- bun-v{MAX_BUN_VERSION}"
 # Default host in dev mode.