const fs = require('fs');
const path = 'd:/برنامج مخازن/index.html';

let html = fs.readFileSync(path, 'utf8');

const oldStr = '<script src="store_contractors_module.js" defer></script>';
const newStr = '<script src="store_module.js" defer></script>\n    <script src="contractors_module.js" defer></script>';

if (html.includes(oldStr)) {
    html = html.replace(oldStr, newStr);
    fs.writeFileSync(path, html, 'utf8');
    console.log('Updated index.html successfully with split modules.');
} else {
    console.log('Old script not found.');
}
