mock程序napi调用时打印日志

Signed-off-by: yy8545 <854551495@qq.com>
This commit is contained in:
yy8545
2023-09-18 16:41:58 +08:00
parent 95ee6d450f
commit 91c1fc1e13
@@ -66,10 +66,12 @@ export function generateIndex(): string {
indexBody += `export function mockRequireNapiFun() {
global.requireNapi = function(...args) {
const globalNapi = global.requireNapiPreview(...args);
if (globalNapi !== undefined) {
return globalNapi;
}
switch (args[0]) {`;
if (globalNapi !== undefined) {\n\t`;
indexBody += 'console.log(`${JSON.stringify(args)} called the dynamic library Api (${JSON.stringify(globalNapi)})`);\n';
indexBody += `return globalNapi;
}\n`;
indexBody += 'console.log(`${JSON.stringify(args[0])} called the mockApi`);\n';
indexBody += `switch (args[0]) {`;
indexBody += caseBody;
const endBody = `}
if (global.hosMockFunc !== undefined) {