Skip to content

Commit

Permalink
chore: improve emscripten patch logger
Browse files Browse the repository at this point in the history
  • Loading branch information
Sec-ant committed Dec 28, 2024
1 parent 2ef3d70 commit ea618e0
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions scripts/babel-plugin-emscripten-patch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ import {

export function emscriptenPatch(): PluginItem {
return {
pre() {
this.declared = false;
this.checked = false;
},
visitor: {
VariableDeclaration(path) {
if (
Expand Down Expand Up @@ -53,6 +57,7 @@ export function emscriptenPatch(): PluginItem {
),
]),
]);
this.declared = true;
}
},
LogicalExpression(path) {
Expand Down Expand Up @@ -82,8 +87,26 @@ export function emscriptenPatch(): PluginItem {
path.replaceWith(newNode);
}
path.skip();
this.checked = true;
}
},
},
post() {
if (!this.declared) {
console.error(
"\x1b[33m! Emscripten JS Patch\x1b[0m: patch variables not declared",
);
}
if (!this.checked) {
console.error(
"\x1b[33m! Emscripten JS Patch\x1b[0m: patch variables not checked",
);
}
if (this.declared && this.checked) {
console.log(
"\x1b[32m✓ Emscripten JS Patch\x1b[0m: patch variables declared and checked",
);
}
},
};
}

0 comments on commit ea618e0

Please sign in to comment.