repositories / dotfiles
dotfiles
bugabingas dorkfiles
owned by admin
nushell/modules/lib.nu
Raw# Check if a binary is available in $env.PATH.
# Throws error if not.
export def require-binary [
bin: string # name of a binary, that should be in $env.PATH
] {
if (which $bin | is-empty) {
error make {
msg: $"`$bin` is not installed or not in PATH"
label: {
text: $"run `which $bin` to verify"
}
}
}
}
export def save-if-changed [
path: path
content: string
] {
if (not ($path | path exists)) or ((open --raw $path) != $content) {
$content | save --force $path
}
}