@codeandmoney/jargal 0.0.0-rc.6 → 0.0.0-rc.8
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/jargal.ts +14 -5
- package/package.json +3 -2
package/jargal.ts
CHANGED
|
@@ -118,12 +118,17 @@ export class Jargal<const in out Context> {
|
|
|
118
118
|
return this as any;
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
-
async write(
|
|
121
|
+
async write(
|
|
122
|
+
write?: (params: {
|
|
123
|
+
savePath: string;
|
|
124
|
+
content: string;
|
|
125
|
+
defultWrite: (params: { savePath: string; content: string }) => Promise<void>;
|
|
126
|
+
}) => void | Promise<void>,
|
|
127
|
+
): Promise<void> {
|
|
122
128
|
if (typeof write === "function") {
|
|
123
129
|
// @ts-expect-error
|
|
124
130
|
for (const renderConfig of this.#context.renderedContent as { savePath: string; content: string }[]) {
|
|
125
|
-
|
|
126
|
-
await write(renderConfig);
|
|
131
|
+
await write({ ...renderConfig, defultWrite });
|
|
127
132
|
}
|
|
128
133
|
|
|
129
134
|
return;
|
|
@@ -132,8 +137,12 @@ export class Jargal<const in out Context> {
|
|
|
132
137
|
// console.log({ renderedContent: this.#context.renderedContent})
|
|
133
138
|
// @ts-expect-error
|
|
134
139
|
for (const renderConfig of this.#context.renderedContent as { savePath: string; content: string }[]) {
|
|
135
|
-
|
|
136
|
-
await writeFile(renderConfig.savePath, new TextEncoder().encode(renderConfig.content), {});
|
|
140
|
+
defultWrite(renderConfig);
|
|
137
141
|
}
|
|
138
142
|
}
|
|
139
143
|
}
|
|
144
|
+
|
|
145
|
+
async function defultWrite(params: { savePath: string; content: string }): Promise<void> {
|
|
146
|
+
await mkdir(dirname(params.savePath), { recursive: true });
|
|
147
|
+
await writeFile(params.savePath, new TextEncoder().encode(params.content), {});
|
|
148
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codeandmoney/jargal",
|
|
3
|
-
"version": "0.0.0-rc.
|
|
3
|
+
"version": "0.0.0-rc.8",
|
|
4
4
|
"description": "Renderer",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Code & Money Team",
|
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
"./old": "./exports.ts",
|
|
16
16
|
".": "./jargal.ts",
|
|
17
17
|
"./types": "./types.ts",
|
|
18
|
-
"./actions": "./actions/exports.ts"
|
|
18
|
+
"./actions": "./actions/exports.ts",
|
|
19
|
+
"./renderer": "./renderer.ts"
|
|
19
20
|
},
|
|
20
21
|
"dependencies": {
|
|
21
22
|
"change-case": "^5.4.4",
|