diff options
| author | Dan Goodliffe <dan@randomdan.homeip.net> | 2019-06-24 21:35:51 +0100 |
|---|---|---|
| committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2019-06-24 21:35:51 +0100 |
| commit | 607cb31facc1e1bf983dd5a6f19c1f916bc3ab78 (patch) | |
| tree | 6e39f531ed6a8dedd694a7cca52aaaa26af34c2c /scripts/toy.groovy | |
| parent | Fix missing const prefixes (diff) | |
| download | toy-607cb31facc1e1bf983dd5a6f19c1f916bc3ab78.zip | |
Support post load module callback for late setup
Diffstat (limited to 'scripts/toy.groovy')
| -rw-r--r-- | scripts/toy.groovy | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/scripts/toy.groovy b/scripts/toy.groovy index 3a0d15a..1d8aa03 100644 --- a/scripts/toy.groovy +++ b/scripts/toy.groovy @@ -60,14 +60,26 @@ return new Object() { .sum() }; def loadModules = { toy -> + final postLoad = [:]; new File("$DATAFOLDER/scripts/toy") .listFiles() .each({s -> if (stateIs("DEBUG")) { - show("Loading $s..."); + show("Loading ${s.name}..."); } - Eval.me(s.text)(toy); + postLoad[s.name] = Eval.me(s.text)(toy); }); + postLoad + .findAll { s, p -> p } + .each { s, p -> + if (stateIs("DEBUG")) { + show("Post load $s..."); + } + p(); + }; + if (stateIs("DEBUG")) { + show("All modules loaded"); + } }; // Utils |
