@codeandmoney/jargal 0.0.0-rc.8 → 0.0.0-rc.9

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.
@@ -1,3 +1,4 @@
1
+ import assert from "node:assert";
1
2
  import { readdir, readFile } from "node:fs/promises";
2
3
  import path, { resolve } from "node:path";
3
4
 
@@ -17,18 +18,23 @@ export async function templates<Scope extends string | undefined = undefined>(pa
17
18
  const removeExtension = engine === "handlebars" ? ".hbs" : "";
18
19
  const scopeKey = params.scope ? params.scope : "default";
19
20
 
20
- let record = { [scopeKey]: {} } as Record<string, TemplatesMap>;
21
+ const record = { [scopeKey]: {} } as Record<string, TemplatesMap>;
21
22
 
22
23
  const resolvedPath = resolve(params.path);
23
24
 
24
25
  for await (const templatePath of walkDir(resolvedPath)) {
26
+ if (path.basename(templatePath).startsWith("_")) {
27
+ continue;
28
+ }
29
+
25
30
  const savePath = path.relative(resolvedPath, templatePath).replace(removeExtension, "");
26
31
 
27
32
  const contentRaw = await readFile(path.resolve(resolvedPath, templatePath));
28
33
  const data: TemplateData = { templateContent: new TextDecoder().decode(contentRaw), templatePath, savePath };
29
34
 
30
35
  if (!params.hooks) {
31
- Object.assign(record[scopeKey]!, { [savePath]: data });
36
+ assert(record[scopeKey]);
37
+ Object.assign(record[scopeKey], { [savePath]: data });
32
38
  continue;
33
39
  }
34
40
 
@@ -40,7 +46,8 @@ export async function templates<Scope extends string | undefined = undefined>(pa
40
46
  [path_, data_] = hook(path_, data_);
41
47
  }
42
48
 
43
- Object.assign(record[scopeKey]!, { [path_]: data_ });
49
+ assert(record[scopeKey]);
50
+ Object.assign(record[scopeKey], { [path_]: data_ });
44
51
  }
45
52
  }
46
53
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codeandmoney/jargal",
3
- "version": "0.0.0-rc.8",
3
+ "version": "0.0.0-rc.9",
4
4
  "description": "Renderer",
5
5
  "license": "MIT",
6
6
  "author": "Code & Money Team",