mirror of
https://github.com/beetbox/beets.git
synced 2025-12-15 21:14:19 +01:00
Create empty user config file if it does not exist
Running `beet config -e` with a non-existing configuration file does not always work (e.g., OSX uses `open` by default, which requires the file to exist). This could occur during e.g. initial setup. Resolve #1480
This commit is contained in:
parent
493fbab1a5
commit
12295376eb
1 changed files with 3 additions and 1 deletions
|
|
@ -1482,11 +1482,13 @@ def config_func(lib, opts, args):
|
|||
|
||||
def config_edit():
|
||||
"""Open a program to edit the user configuration.
|
||||
An empty config file is created if no existing config file exists.
|
||||
"""
|
||||
path = config.user_config_path()
|
||||
|
||||
editor = os.environ.get('EDITOR')
|
||||
try:
|
||||
if not os.path.isfile(path):
|
||||
open(path, 'w+').close()
|
||||
util.interactive_open(path, editor)
|
||||
except OSError as exc:
|
||||
message = "Could not edit configuration: {0}".format(exc)
|
||||
|
|
|
|||
Loading…
Reference in a new issue