Skip to content

Commit

Permalink
fix conditionally create output dir
Browse files Browse the repository at this point in the history
  • Loading branch information
siph committed Mar 31, 2024
1 parent 25a7025 commit 25e8bb3
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions yt-watcher/config.nu
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ export def get_config [

try {
let config = open $config_file
mkdir $config.output

if not ($config.output | path exists) {
mkdir $config.output
}

return $config
} catch {
let default_config = {
Expand All @@ -39,8 +43,15 @@ export def get_config [
}

log warning "Exporting default configuration..."
mkdir $"($env.XDG_CONFIG_HOME)/yt-watcher"
mkdir $default_config.output

if not ($"($env.XDG_CONFIG_HOME)/yt-watcher" | path exists) {
mkdir $"($env.XDG_CONFIG_HOME)/yt-watcher"
}

if not ($default_config.output | path exists) {
mkdir $default_config.output
}

$default_config | to yaml | save $config_file

return $default_config
Expand Down

0 comments on commit 25e8bb3

Please sign in to comment.