Skip to content

Commit 7d05ebc

Browse files
committed
Set mdsh cache directory globally
1 parent 1c0ccc0 commit 7d05ebc

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

Config.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ Either way, service targets are created for any services that don't already have
5252
```shell
5353
loco_loadproject() {
5454
cd "$LOCO_ROOT"; [[ ! -f .env ]] || export-env .env
55+
mdsh-use-cache "$LOCO_ROOT/.doco-cache/includes"
5556
export COMPOSE_FILE=$LOCO_ROOT/.doco-cache.json COMPOSE_PATH_SEPARATOR=$'\n'
5657
local json=$COMPOSE_FILE; DOCO_CONFIG=
5758

@@ -191,7 +192,6 @@ Source the mdsh compilation of the specified markdown file, saving it in *cache
191192
include() {
192193
realpath.absolute "$1"
193194
if [[ ! "${2-}" ]]; then
194-
local MDSH_CACHE="$LOCO_ROOT/.doco-cache/includes"
195195
@require "doco-include:$REPLY" mdsh-run "$1" ""
196196
else
197197
__include() { mdsh-make "$1" "$2"; source "$2"; }

bin/doco

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,7 @@ loco_preconfig() {
452452
}
453453
loco_loadproject() {
454454
cd "$LOCO_ROOT"; [[ ! -f .env ]] || export-env .env
455+
mdsh-use-cache "$LOCO_ROOT/.doco-cache/includes"
455456
export COMPOSE_FILE=$LOCO_ROOT/.doco-cache.json COMPOSE_PATH_SEPARATOR=$'\n'
456457
local json=$COMPOSE_FILE; DOCO_CONFIG=
457458
@@ -526,7 +527,6 @@ export-source() {
526527
include() {
527528
realpath.absolute "$1"
528529
if [[ ! "${2-}" ]]; then
529-
local MDSH_CACHE="$LOCO_ROOT/.doco-cache/includes"
530530
@require "doco-include:$REPLY" mdsh-run "$1" ""
531531
else
532532
__include() { mdsh-make "$1" "$2"; source "$2"; }

specs/Config.cram.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,30 @@ Either way, service targets are created for any services that don't already have
9999
> doco.dump() { echo "${DOCO_SERVICES[@]}"; echo "$FOO"; }
100100
> event on "finalize project" echo "hi!"
101101
> event on "before commands" declare -p __doco_target__2d_2dall
102+
> include "$TESTDIR/../README.md"
103+
> include "dummy.md" test-caching.sh
104+
> include "dummy.md" # multiple includes of same file are a no-op
105+
> EOF
106+
107+
$ cat <<'EOF' >dummy.md
108+
> ```shell
109+
> echo "dummy loaded"
110+
> ```
102111
> EOF
103112
104113
$ run-doco t dump
114+
dummy loaded
105115
hi!
106-
declare -ar __doco_target__2d_2dall=([0]="t")
116+
declare -ar __doco_target__2d_2dall=([0]="t" [1]="example1")
107117
t
108118
baz'bar
109119
120+
$ ls .doco-cache/includes # cached compiled README
121+
*%2Fspecs%2F..%2FREADME.md (glob)
122+
123+
$ cat test-caching.sh
124+
echo "dummy loaded"
125+
110126
# doco command(s) can't be run from config:
111127
112128
$ echo 'doco --all' >.doco

0 commit comments

Comments
 (0)