globalbridge-lsf-custom
Version:
GlobalBridge in-house labeling tool, originating from LSF.
26 lines (20 loc) • 991 B
JavaScript
const fs = require('fs');
const bundleFilePath = './build/static/js/main.js';
fs.readFile(bundleFilePath, 'utf8', (err, data) => {
if (err) {
console.error(`Error reading file: ${err}`);
return;
}
// Replace all occurrences of Math.random() with (crypto.getRandomValues(new Uint32Array(1))[0]/2**32)
const updatedData = data.replace(/Math\.random\(\)/g, '(crypto.getRandomValues(new Uint32Array(1))[0]/2**32)');
// Replace all occurrences of plain Math.random with (crypto.getRandomValues(new Uint32Array(1))[0]/2**32)
const finalUpdatedData = updatedData.replace(/Math\.random/g, '(crypto.getRandomValues(new Uint32Array(1))[0]/2**32)');
// Write the updated content back to the file
fs.writeFile(bundleFilePath, finalUpdatedData, 'utf8', (err) => {
if (err) {
console.error(`Error writing file: ${err}`);
} else {
console.log(`Cleanup of Math.random() completed successfully in ${bundleFilePath}`);
}
});
});