@npmcli/template-oss 4.4.0 → 4.4.1
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.
- package/lib/util/template.js +10 -3
- package/package.json +1 -1
package/lib/util/template.js
CHANGED
|
@@ -10,14 +10,21 @@ const partialName = (s) => basename(s, extname(s)) // remove extension
|
|
|
10
10
|
.replace(/^_/, '') // remove leading underscore
|
|
11
11
|
.replace(/-([a-z])/g, (_, g) => g.toUpperCase()) // camelcase
|
|
12
12
|
|
|
13
|
-
const makePartials = (dir,
|
|
13
|
+
const makePartials = (dir, isBase) => {
|
|
14
14
|
const partials = fs.readdirSync(dir).reduce((acc, f) => {
|
|
15
15
|
const partial = fs.readFileSync(join(dir, f)).toString()
|
|
16
16
|
const name = partialName(f)
|
|
17
|
-
|
|
18
|
-
if (
|
|
17
|
+
|
|
18
|
+
if (isBase) {
|
|
19
|
+
// in the default dir, everything is a partial
|
|
20
|
+
// and also gets set with a default prefix for extending
|
|
21
|
+
acc[name] = partial
|
|
19
22
|
acc[partialName(`default-${name}`)] = partial
|
|
23
|
+
} else if (f.startsWith('_')) {
|
|
24
|
+
// otherwise only _ files get set as partials
|
|
25
|
+
acc[name] = partial
|
|
20
26
|
}
|
|
27
|
+
|
|
21
28
|
return acc
|
|
22
29
|
}, {})
|
|
23
30
|
|