mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-31 10:37:13 +02:00
Implement config.get_default_env()
This commit is contained in:
@ -376,6 +376,13 @@ class ProjectConfigBase(object):
|
|||||||
def default_envs(self):
|
def default_envs(self):
|
||||||
return self.get("platformio", "default_envs", [])
|
return self.get("platformio", "default_envs", [])
|
||||||
|
|
||||||
|
def get_default_env(self):
|
||||||
|
default_envs = self.default_envs()
|
||||||
|
if default_envs:
|
||||||
|
return default_envs[0]
|
||||||
|
envs = self.envs()
|
||||||
|
return envs[0] if envs else None
|
||||||
|
|
||||||
def validate(self, envs=None, silent=False):
|
def validate(self, envs=None, silent=False):
|
||||||
if not os.path.isfile(self.path):
|
if not os.path.isfile(self.path):
|
||||||
raise exception.NotPlatformIOProjectError(os.path.dirname(self.path))
|
raise exception.NotPlatformIOProjectError(os.path.dirname(self.path))
|
||||||
|
@ -183,6 +183,7 @@ def test_envs(config):
|
|||||||
"extra_2",
|
"extra_2",
|
||||||
]
|
]
|
||||||
assert config.default_envs() == ["base", "extra_2"]
|
assert config.default_envs() == ["base", "extra_2"]
|
||||||
|
assert config.get_default_env() == "base"
|
||||||
|
|
||||||
|
|
||||||
def test_options(config):
|
def test_options(config):
|
||||||
|
Reference in New Issue
Block a user