Fix syntax errors in perfis-catalog.js for Vite compatibility
This commit is contained in:
22
unwrap_scripts.js
Normal file
22
unwrap_scripts.js
Normal file
@@ -0,0 +1,22 @@
|
||||
const fs = require('fs');
|
||||
const path = 'm:/OFICIAIS E FUNCIONANDO/STEELBASE/js/sections/perfis-catalog.js';
|
||||
let c = fs.readFileSync(path, 'utf8');
|
||||
|
||||
// Unescape some mangled ones
|
||||
c = c.replace(/\\`/g, '`');
|
||||
|
||||
// Match <script> tags inside functions and Extract them out of the return ` ... `
|
||||
// but after the function.
|
||||
|
||||
// 1. Find 'return ` ... <script> ... </script> ... `;'
|
||||
// 2. Replace with 'return ` ... ... `; <script logic> ...'
|
||||
|
||||
// But a simpler way: just REMOVE the <script> and </script> tags ONLY if they are inside return ` ... `;
|
||||
// and keep the content.
|
||||
|
||||
c = c.replace(/return\s+`([\s\S]*?)<script>([\s\S]*?)<\/script>([\s\S]*?)`;/gs, (match, before, script, after) => {
|
||||
return 'return `' + before + after + '`; \n\n' + script + '\n\n';
|
||||
});
|
||||
|
||||
fs.writeFileSync(path, c);
|
||||
console.log('Unwrapped scripts in perfis-catalog.js');
|
||||
Reference in New Issue
Block a user