Skip to content

Commit

Permalink
Module handles exitcode 1 from bash-env-json (#37)
Browse files Browse the repository at this point in the history
I'm no longer updating the plugin though, that is deprecated and will be removed soon.
  • Loading branch information
tesujimath authored Oct 28, 2024
1 parent 87a4ad9 commit 12e6933
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
15 changes: 9 additions & 6 deletions bash-env.nu
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,23 @@ export def main [
[]
}

let raw = ($in | str join "\n") | bash-env-json ...($fn_args ++ $path_args) | from json
let raw = ($in | str join "\n") | bash-env-json ...($fn_args ++ $path_args) | complete
let raw_json = $raw.stdout | from json

let error = $raw | get -i error
let error = $raw_json | get -i error
if $error != null {
error make { msg: $error }
} else if $raw.exit_code != 0 {
error make { msg: $"unexpected failure from bash-env-json ($raw.stderr)" }
}

if ($export | is-not-empty) {
print "warning: --export is deprecated, use --shellvars(-s) instead"
let exported_shellvars = ($raw.shellvars | select -i ...$export)
$raw.env | merge ($exported_shellvars)
let exported_shellvars = ($raw_json.shellvars | select -i ...$export)
$raw_json.env | merge ($exported_shellvars)
} else if $shellvars or ($fn | is-not-empty) {
$raw
$raw_json
} else {
$raw.env
$raw_json.env
}
}
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 12e6933

Please sign in to comment.