mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-08 17:54:15 +02:00
[wgem] config: allowing to use a custom electron version
This commit is contained in:
@@ -4,19 +4,31 @@ from pathlib import Path
|
||||
import yaml
|
||||
|
||||
from bauh.api.constants import CONFIG_PATH
|
||||
from bauh.commons import util
|
||||
from bauh.gems.web import CONFIG_FILE
|
||||
|
||||
|
||||
def read_config() -> dict:
|
||||
def read_config(update_file: bool = False) -> dict:
|
||||
default_config = {
|
||||
'environment': {
|
||||
'system': False,
|
||||
'electron': {'version': None}
|
||||
}
|
||||
}
|
||||
if not os.path.exists(CONFIG_FILE):
|
||||
config = {'environment': {'system': False}}
|
||||
|
||||
Path(CONFIG_PATH).mkdir(parents=True, exist_ok=True)
|
||||
|
||||
with open(CONFIG_FILE, 'w+') as f:
|
||||
f.write(yaml.dump(config))
|
||||
f.write(yaml.dump(default_config))
|
||||
|
||||
else:
|
||||
with open(CONFIG_FILE) as f:
|
||||
config = yaml.safe_load(f.read())
|
||||
local_config = yaml.safe_load(f.read())
|
||||
|
||||
return config
|
||||
util.deep_update(default_config, local_config)
|
||||
|
||||
if update_file:
|
||||
with open(CONFIG_FILE, 'w+') as f:
|
||||
f.write(yaml.dump(default_config))
|
||||
|
||||
return default_config
|
||||
|
||||
Reference in New Issue
Block a user