Spaces:
Sleeping
Sleeping
File size: 712 Bytes
d381a4c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | const fs = require('fs');
const path = require('path');
const dir = 'C:/LLM/carpool/src';
const files = fs.readdirSync(dir).filter(f => f.endsWith('.jsx'));
let totalReplaced = 0;
files.forEach(f => {
const p = path.join(dir, f);
let c = fs.readFileSync(p, 'utf8');
// Replace http://${window.location.hostname}:3001/api with /api
// We match the exact template literal string usage or regular string usage
const targetPattern = /http:\/\/\$\{window\.location\.hostname\}:3001/g;
if (targetPattern.test(c)) {
c = c.replace(targetPattern, '');
fs.writeFileSync(p, c);
console.log('Updated ' + f);
totalReplaced++;
}
});
console.log('Total files updated: ' + totalReplaced);
|