@zwa73/dev-utils 1.0.32 → 1.0.34
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/dist/UtilDevTool.d.ts +1 -1
- package/dist/UtilDevTool.js +2 -1
- package/package.json +1 -1
- package/src/UtilDevTool.ts +3 -2
package/dist/UtilDevTool.d.ts
CHANGED
@@ -51,6 +51,6 @@ export declare namespace UtilDT {
|
|
51
51
|
* @param codeText - 文本
|
52
52
|
* @param targetPath - 目标文件 默认为去除".macro"的同名文件
|
53
53
|
*/
|
54
|
-
export function $macro(regionId: string, codeText: string, targetPath?: string): Promise<void>;
|
54
|
+
export function $macro(regionId: string, codeText: string | (() => string | Promise<string>), targetPath?: string): Promise<void>;
|
55
55
|
export {};
|
56
56
|
}
|
package/dist/UtilDevTool.js
CHANGED
@@ -162,7 +162,8 @@ var UtilDT;
|
|
162
162
|
return;
|
163
163
|
}
|
164
164
|
const match = getregex().exec(text);
|
165
|
-
const
|
165
|
+
const strText = typeof codeText === "function" ? await codeText() : codeText;
|
166
|
+
const mapText = strText.split('\n').map((line) => `${match[1]}${line}`).join('\n');
|
166
167
|
const ntext = text.replace(getregex(), `$1$2${mapText}\n$4`);
|
167
168
|
await fs.promises.writeFile(baseFilePath, ntext, 'utf-8');
|
168
169
|
};
|
package/package.json
CHANGED
package/src/UtilDevTool.ts
CHANGED
@@ -137,7 +137,7 @@ export async function batchNode(filepath:string|string[],opt?:BatchNodeOpt) {
|
|
137
137
|
* @param codeText - 文本
|
138
138
|
* @param targetPath - 目标文件 默认为去除".macro"的同名文件
|
139
139
|
*/
|
140
|
-
export async function $macro(regionId:string,codeText:string,targetPath?:string){
|
140
|
+
export async function $macro(regionId:string,codeText:string|(()=>string|Promise<string>),targetPath?:string){
|
141
141
|
const loc = UtilFunc.getFuncLoc(2);
|
142
142
|
if(!loc){
|
143
143
|
SLogger.error(`UtilDT.$macro 未能找到函数位置`);
|
@@ -162,7 +162,8 @@ export async function $macro(regionId:string,codeText:string,targetPath?:string)
|
|
162
162
|
return;
|
163
163
|
}
|
164
164
|
const match = getregex().exec(text)!;
|
165
|
-
const
|
165
|
+
const strText = typeof codeText === "function" ? await codeText() : codeText;
|
166
|
+
const mapText = strText.split('\n').map((line)=>`${match[1]}${line}`).join('\n');
|
166
167
|
const ntext = text.replace(getregex(), `$1$2${mapText}\n$4`);
|
167
168
|
await fs.promises.writeFile(baseFilePath, ntext, 'utf-8');
|
168
169
|
}
|