Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 33 additions & 19 deletions modules/script/v2/script.nu
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,42 @@ def main [config: string]: nothing -> nothing {
| default [] snippets

let script_dir = [$env.CONFIG_DIRECTORY scripts] | path join
cd $script_dir
glob ./**/*{.sh,.nu,.py}
| each { chmod +x $in }

$config.scripts
| each {|script|
print -e $'(ansi green)Running script: (ansi cyan)($script)(ansi reset)'

let script_path = [$script_dir $script] | path join
chmod +x $script_path

try {
^$script_path
print -e $'(ansi green)Finished running script (ansi cyan)($script)(ansi reset)'
} catch {
return (error make {
msg: $'(ansi red)Failed to run (ansi cyan)($script)(ansi reset)'
})
if ($script_dir | path exists) {
cd $script_dir
glob ./**/*{.sh,.nu,.py}
| each { chmod +x $in }

$config.scripts
| each {|script|
print -e $'(ansi green)Running script: (ansi cyan)($script)(ansi reset)'

let script_path = [$script_dir $script] | path join

if ($script | path exists) {
chmod +x $script_path

try {
^$script_path
print -e $'(ansi green)Finished running script (ansi cyan)($script)(ansi reset)'
} catch {
return (error make {
msg: $'(ansi red)Failed to run (ansi cyan)($script)(ansi reset)'
})
}
} else {
return (error make {
msg: $"(ansi red)Script (ansi cyan)($script_path)(ansi red) does not exist.(ansi reset)\nMake sure your script exists in (ansi yellow)./files/scripts(ansi reset) in your repo."
})
}
}
}

cd -
cd -
} else if ($config.scripts | is-not-empty) {
return (error make {
msg: $"(ansi red)Cannot declare scripts to run if (ansi cyan)($script_dir)(ansi red) doesn't exist.\n(ansi reset)Make sure there is a (ansi cyan)scripts/(ansi reset) directory in your (ansi yellow)./files/(ansi reset) directory in your repo."
})
}

$config.snippets
| each {|snippet|
Expand Down
Loading