Description
As a developer using Vite+ I want to be able to source vp into nushell so that I can still use my main shell.
This includes wrapping the env use command and completions for vp.
Suggested solution
I've already implemented a env.nu that can be sourced in nushell like so 'source ~/.vite-plus/env.nu'
# Custom completer for the vp wrapper using fish completions
def "nu-complete vp" [context: string] {
let fish_comp_path = ($env.HOME | path join ".vite-plus/completion/vp.fish")
let fish_cmd = $"source '($fish_comp_path)'; complete '--do-complete=($context)'"
fish --command $fish_cmd | from tsv --flexible --noheaders --no-infer | rename value description | update value {|row|
let value = $row.value
let need_quote = ['\' ',' '[' ']' '(' ')' ' ' '\t' "'" '"' "`"] | any {$in in $value}
if ($need_quote and ($value | path exists)) {
let expanded_path = if ($value starts-with ~) {$value | path expand --no-symlink} else {$value}
$'"($expanded_path | str replace --all "\"" "\\\"")"'
} else {$value}
}
}
export def --env --wrapped vp [...args: string@"nu-complete vp"] { match $args {
["env", "use", ..] => {
let out = (with-env { VITE_PLUS_ENV_USE_EVAL_ENABLE: "1" } {
^vp ...$args
})
let out_lines = ($out | lines)
let exports = (
$out_lines | find -r '^export ' | parse -r '^export (?P<key>\w+)=["'']?(?P<value>[^"'']+)["'']?' | reduce -f {} {|it, acc| $acc | insert $it.key $it.value}
)
if not ($exports | is-empty) {
load-env $exports
}
let unsets = (
$out_lines | find -r '^unset ' | parse -r '^unset (?P<key>\w+)' | get key
)
for key in $unsets { hide-env $key }
}
_ => { ^vp ...$args }
} }
Alternative
No response
Additional context
No response
Validations
Description
As a developer using Vite+ I want to be able to source vp into nushell so that I can still use my main shell.
This includes wrapping the env use command and completions for vp.
Suggested solution
I've already implemented a env.nu that can be sourced in nushell like so 'source ~/.vite-plus/env.nu'
Alternative
No response
Additional context
No response
Validations