/** * We've seen cases where the functions inside safari-notifications.js are not found. * This is our attempt to ensure that all the functions are available. */ const fs = require("fs"); const path = require("path"); const swScriptsDir = path.resolve(__dirname, "sw_scripts"); const outputFile = path.resolve(__dirname, "sw_scripts-combined.js"); // Read all files in the sw_scripts directory fs.readdir(swScriptsDir, (err, files) => { if (err) { console.error("Error reading directory:", err); return; } // Combine files content into one script const combinedContent = files .filter((file) => path.extname(file) === ".js") .map((file) => fs.readFileSync(path.join(swScriptsDir, file), "utf8")) .join("\n"); // Write the combined content to the output file fs.writeFileSync(outputFile, combinedContent, "utf8"); console.log("Service worker files combined."); });