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