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 ln ./rootdir ./projectmountroot
8 ln ./rootdir ./themes/mytheme/thememountroot
9 ln ./rootdir ./themes/mytheme/thememountparent
10
11 hugo
12
13 grep 'OK' public/index.html
14 ! grep 'FAIL' public/index.html
15
16 tree public
17
18 stdout modassetok
19 ! stdout modassetsymlink
20 stdout 'modstatictok'
21 ! stdout 'modstaticsymlink'
22 stdout pageok
23 ! stdout pagesymlink
24 ! stdout rootdirfile
25
26 -- hugo.toml --
27 disableKinds = ["taxonomy", "term", "rss"]
28 [[module.imports]]
29 path = 'mytheme'
30 [[module.mounts]]
31 source = 'assets'
32 target = 'assets'
33 [[module.mounts]]
34 source = 'projectmountroot'
35 target = 'assets/projectmountroot'
36 -- themes/mytheme/hugo.toml --
37 [[module.mounts]]
38 source = 'assets'
39 target = 'assets'
40 [[module.mounts]]
41 source = 'static'
42 target = 'static'
43 [[module.mounts]]
44 source = 'thememountroot'
45 target = 'assets/thememountroot'
46 [[module.mounts]]
47 source = 'thememountparent/subdir'
48 target = 'assets/thememountparent'
49 -- README.md --
50 Read me.
51 -- layouts/all.html --
52 {{ with resources.Get "modassetok.txt"}}OK {{ .Publish }}{{ else }}FAIL{{ end }}
53 {{ with resources.Get "modassetsymlink.txt"}}FAIL {{ .Publish }}{{ else }}OK{{ end }}
54 {{ with resources.GetMatch "modassetsymlink.txt"}}FAIL {{ .Publish }}{{ else }}OK{{ end }}
55 {{ with resources.GetMatch "myassets/symlinkdir/**"}}FAIL {{ .Publish }}{{ else }}OK{{ end }}
56 {{ with resources.Get "myassets/symlinkdir/rootdirfile1.txt"}}FAIL {{ .Publish }}{{ else }}OK{{ end }}
57 {{ with resources.Get "projectmountroot/rootdirfile1.txt"}}FAIL {{ .Publish }}{{ else }}OK{{ end }}
58 {{ with resources.Get "thememountroot/rootdirfile1.txt"}}FAIL {{ .Publish }}{{ else }}OK{{ end }}
59 {{ with resources.Get "thememountparent/rootdirfile3.txt"}}FAIL {{ .Publish }}{{ else }}OK{{ end }}
60 {{ with resources.GetMatch "*mountroot/**"}}FAIL {{ .Publish }}{{ else }}OK{{ end }}
61 Page: {{ .RelPermalink }}|{{ .Content }}|
62
63 {{/* os template package. */}}
64 {{ $symFilePath := "content/pagesymlink.md" }}
65
66 {{ with os.ReadDir "assets/myassets/symlinkdir" }}FAIL {{ len . }}{{ else }}OK{{ end }}
67 {{ template "check-os-path" $symFilePath }}
68 {{ $symFilePath = "assets/myassets/symlinkdir/rootdirfile1.txt" }}
69 {{ template "check-os-path" $symFilePath }}
70 {{ $symFilePath = "assets/myassets/symlinkdir/subdir/rootdirfile3.txt" }}
71 {{ template "check-os-path" $symFilePath }}
72
73 {{ define "check-os-path" }}
74 {{ with os.Stat . }}FAIL{{ else }}OK{{ end }}
75 {{ with os.ReadFile . }}FAIL{{ else }}OK{{ end }}
76 {{ with os.FileExists . }}FAIL{{ else }}OK{{ end }}
77 {{ end }}
78
79 -- content/pageok.md --
80 -- themes/mytheme/assets/modassetok.txt --
81 Content.
82 -- themes/mytheme/static/modstatictok.txt --
83 Content.
84 -- rootfile.txt --
85 Root Content.
86 -- assets/myassets/myfile.txt --
87 My file.
88 -- rootdir/rootdirfile1.txt --
89 Rootdirfile1 content.
90 -- rootdir/rootdirfile2.txt --
91 Rootdirfile2 content.
92 -- rootdir/subdir/rootdirfile3.txt --
93 Rootdirfile3 content.
94
95