nuno revised this gist 1 month ago. Go to revision
1 file changed, 20 insertions
gistfile1.txt(file created)
| @@ -0,0 +1,20 @@ | |||
| 1 | + | function load_module() { | |
| 2 | + | local name="$1" | |
| 3 | + | ||
| 4 | + | module::loaded "$name" && return 0 | |
| 5 | + | ||
| 6 | + | local path | |
| 7 | + | path="$(ctx::modules)/${name}.module.sh" | |
| 8 | + | ||
| 9 | + | if [[ ! -f "$path" ]]; then | |
| 10 | + | log::error "Module not found: ${name} (${path})" | |
| 11 | + | return 1 | |
| 12 | + | fi | |
| 13 | + | ||
| 14 | + | source "$path" | |
| 15 | + | _LOADED_MODULES["$name"]=1 | |
| 16 | + | ||
| 17 | + | core::call_if_exists "$(module::fn "$name" on_load)" | |
| 18 | + | ||
| 19 | + | return 0 | |
| 20 | + | } | |
Newer
Older