Improve dotenv parsing

main
Julius Riegel 3 weeks ago
parent 796fbf2131
commit e7768b4da8
No known key found for this signature in database
GPG Key ID: F26D704A1D3394EB

@ -98,3 +98,8 @@ $env.LTEX_GLOBAL_STORAGE_PATH = "{{dirs.data}}/ltex/"
{{#if-installed librewolf}}
$env.BROWSER = "librewolf"
{{/if-installed}}
{{#if (eq ctx.environment "unitb")}}
$env.OPENSSL_DIR = "/home/linuxbrew/.linuxbrew"
$env.OPENSSL_STATIC = true
{{/if}}

@ -95,7 +95,19 @@ export def --env dotenv [file=".env"] {
}
( open $file
| lines
| each { parse "{key}={value}" | first | { $in.key: $in.value} }
| where $it !~ "^\\s*#.*"
| each {|line|
try {
$line | parse "{key}=\"{value}\"" | first | { $in.key: ($"\"($in.value)\"" | from nuon) }
} catch {
try {
$line | parse "{key}={value}" | first | { $in.key: $in.value }
} catch {
null
}
}
}
| where $it != null
| reduce --fold {} {|it, acc| $acc | merge $it }
| load-env $in
)

Loading…
Cancel
Save