@marko/compiler 5.39.66 → 5.40.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -220,9 +220,8 @@ class TaglibLoader {
|
|
|
220
220
|
// The "tags-dir" property is used to supporting scanning
|
|
221
221
|
// of a directory to discover custom tags. Scanning a directory
|
|
222
222
|
// is a much simpler way for a developer to create custom tags.
|
|
223
|
-
//
|
|
224
|
-
//
|
|
225
|
-
// one level deep.
|
|
223
|
+
// Each tag is a file or directory named after the tag; non-tag
|
|
224
|
+
// directories are scanned one level deep for nested tags.
|
|
226
225
|
var taglib = this.taglib;
|
|
227
226
|
var path = this.filePath;
|
|
228
227
|
var dirname = this.dirname;
|
|
@@ -33,6 +33,11 @@ const searchFiles = [
|
|
|
33
33
|
{ name: "transform", type: "transform" }];
|
|
34
34
|
|
|
35
35
|
|
|
36
|
+
// Directories skipped when crawling groups for nested tags: dot-directories
|
|
37
|
+
// (e.g. `.git`) and discovery-root folders (`tags`/`components`), which stay
|
|
38
|
+
// private to their location (e.g. a nested `tags/tags`).
|
|
39
|
+
const ignoredDirName = /^(?:\.|components$|tags$)/;
|
|
40
|
+
|
|
36
41
|
function createDefaultTagDef() {
|
|
37
42
|
return {
|
|
38
43
|
attributes: {
|
|
@@ -106,6 +111,14 @@ function hasFile(tagDef) {
|
|
|
106
111
|
return false;
|
|
107
112
|
}
|
|
108
113
|
|
|
114
|
+
function isDirectory(path) {
|
|
115
|
+
try {
|
|
116
|
+
return taglibConfig.fs.statSync(path).isDirectory();
|
|
117
|
+
} catch (_) {
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
109
122
|
/**
|
|
110
123
|
* @param {String} tagsConfigPath path to tag definition file
|
|
111
124
|
* @param {String} tagsConfigDirname path to directory of tags config file (should be path.dirname(tagsConfigPath))
|
|
@@ -120,9 +133,11 @@ taglib,
|
|
|
120
133
|
dependencyChain)
|
|
121
134
|
{
|
|
122
135
|
let prefix;
|
|
136
|
+
let nested;
|
|
123
137
|
|
|
124
138
|
if (typeof dir === "object") {
|
|
125
139
|
prefix = dir.prefix;
|
|
140
|
+
nested = dir.nested;
|
|
126
141
|
dir = dir.path;
|
|
127
142
|
}
|
|
128
143
|
|
|
@@ -181,10 +196,26 @@ dependencyChain)
|
|
|
181
196
|
". Neither a renderer or a template was found for tag. " +
|
|
182
197
|
JSON.stringify(tagDef, null, 2)
|
|
183
198
|
);
|
|
184
|
-
} else {
|
|
185
|
-
// Skip this directory... there doesn't appear to be anything in it
|
|
186
|
-
continue;
|
|
187
199
|
}
|
|
200
|
+
|
|
201
|
+
// Not a tag itself: crawl one level into grouping directories for
|
|
202
|
+
// nested tags. Dot-directories and `tags`/`components` folders are
|
|
203
|
+
// skipped so they stay private to their location.
|
|
204
|
+
if (
|
|
205
|
+
!nested &&
|
|
206
|
+
!ignoredDirName.test(childFilename) &&
|
|
207
|
+
isDirectory(tagDirname))
|
|
208
|
+
{
|
|
209
|
+
scanTagsDir(
|
|
210
|
+
tagsConfigPath,
|
|
211
|
+
tagsConfigDirname,
|
|
212
|
+
{ path: tagDirname, prefix, nested: true },
|
|
213
|
+
taglib,
|
|
214
|
+
dependencyChain.append(childFilename)
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
continue;
|
|
188
219
|
}
|
|
189
220
|
}
|
|
190
221
|
}
|