@codeandmoney/jargal 0.0.0-rc.0 → 0.0.0-rc.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/actions/load-templates.ts +8 -6
- package/package.json +1 -1
- package/types.ts +1 -0
|
@@ -3,20 +3,22 @@ import { readdir, readFile } from "node:fs/promises";
|
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
|
|
5
5
|
export function loadTemplates(templatesPath: string, scope?: string): ContextAction {
|
|
6
|
-
return async function execute() {
|
|
7
|
-
const templates
|
|
6
|
+
return async function execute(params) {
|
|
7
|
+
const record = { ...params.context.templates } as Record<string, Map<string, { fullPath: string; realativePath: string; content: string }>>;
|
|
8
|
+
|
|
9
|
+
if (scope) {
|
|
10
|
+
Object.assign(record, { [scope]: new Map() });
|
|
11
|
+
}
|
|
8
12
|
|
|
9
13
|
for await (const fullPath of walkDir(templatesPath)) {
|
|
10
14
|
const realativePath = path.relative(templatesPath, fullPath);
|
|
11
15
|
|
|
12
16
|
const contentRaw = await readFile(path.resolve(templatesPath, fullPath));
|
|
13
17
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
templates.set(key, { content: new TextDecoder().decode(contentRaw), fullPath, realativePath });
|
|
18
|
+
record[scope ? scope : "templates"]?.set(realativePath, { content: new TextDecoder().decode(contentRaw), fullPath, realativePath });
|
|
17
19
|
}
|
|
18
20
|
|
|
19
|
-
return
|
|
21
|
+
return record;
|
|
20
22
|
};
|
|
21
23
|
}
|
|
22
24
|
|
package/package.json
CHANGED
package/types.ts
CHANGED