Debian Codegraph @

testscripts/commands/no_symlinks.txt

raw
1 [windows] skip
2
3 ln ./rootfile.txt ./themes/mytheme/assets/modassetsymlink.txt
4 ln ./rootfile.txt ./themes/mytheme/static/modstaticsymlink.txt
5 ln ./README.md ./content/pagesymlink.md
6 ln ./rootdir ./assets/myassets/symlinkdir
7
8 hugo
9
10 grep 'OK' public/index.html
11 ! grep 'FAIL' public/index.html
12
13 tree public
14
15 stdout modassetok
16 ! stdout modassetsymlink
17 stdout 'modstatictok'
18 ! stdout 'modstaticsymlink'
19 stdout pageok
20 ! stdout pagesymlink
21 ! stdout rootdirfile
22
23 -- hugo.toml --
24 disableKinds = ["taxonomy", "term", "rss"]
25 [[module.imports]]
26 path = 'mytheme'
27 -- README.md --
28 Read me.
29 -- layouts/all.html --
30 {{ with resources.Get "modassetok.txt"}}OK {{ .Publish }}{{ else }}FAIL{{ end }}
31 {{ with resources.Get "modassetsymlink.txt"}}FAIL {{ .Publish }}{{ else }}OK{{ end }}
32 {{ with resources.GetMatch "modassetsymlink.txt"}}FAIL {{ .Publish }}{{ else }}OK{{ end }}
33 {{ with resources.GetMatch "myassets/symlinkdir/**"}}FAIL {{ .Publish }}{{ else }}OK{{ end }}
34 {{ with resources.Get "myassets/symlinkdir/rootdirfile1.txt"}}FAIL {{ .Publish }}{{ else }}OK{{ end }}
35 Page: {{ .RelPermalink }}|{{ .Content }}|
36
37 {{/* os template package. */}}
38 {{ $symFilePath := "content/pagesymlink.md" }}
39
40 {{ with os.ReadDir "assets/myassets/symlinkdir" }}FAIL {{ len . }}{{ else }}OK{{ end }}
41 {{ template "check-os-path" $symFilePath }}
42 {{ $symFilePath = "assets/myassets/symlinkdir/rootdirfile1.txt" }}
43 {{ template "check-os-path" $symFilePath }}
44 {{ $symFilePath = "assets/myassets/symlinkdir/subdir/rootdirfile3.txt" }}
45 {{ template "check-os-path" $symFilePath }}
46
47 {{ define "check-os-path" }}
48 {{ with os.Stat . }}FAIL{{ else }}OK{{ end }}
49 {{ with os.ReadFile . }}FAIL{{ else }}OK{{ end }}
50 {{ with os.FileExists . }}FAIL{{ else }}OK{{ end }}
51 {{ end }}
52
53 -- content/pageok.md --
54 -- themes/mytheme/assets/modassetok.txt --
55 Content.
56 -- themes/mytheme/static/modstatictok.txt --
57 Content.
58 -- rootfile.txt --
59 Root Content.
60 -- assets/myassets/myfile.txt --
61 My file.
62 -- rootdir/rootdirfile1.txt --
63 Rootdirfile1 content.
64 -- rootdir/rootdirfile2.txt --
65 Rootdirfile2 content.
66 -- rootdir/subdir/rootdirfile3.txt --
67 Rootdirfile3 content.
68
69