MCPcopy Index your code
hub / github.com/MALSync/MALSync / addPlayerUrls

Function addPlayerUrls

webpackConfig/autoUrls.mjs:206–237  ·  view source on GitHub ↗
(key, urls)

Source from the content-addressed store, hash-verified

204}
205
206function addPlayerUrls(key, urls) {
207 logFoundUrls(key, urls, URL_TYPES.PLAYER);
208
209 let file = fs.readFileSync(path.resolve('./src/pages/playerUrls.js'), 'utf8');
210
211 const comment = ` // auto-${key}-replace-dont-remove`;
212
213 let data = '';
214 let addedCount = 0;
215 const existingUrls = [];
216 for (const url of urls) {
217 if (!file.includes(url)) {
218 data += ` '*://${url}',\n`;
219 addedCount++;
220 } else {
221 existingUrls.push(url);
222 }
223 }
224
225 if (existingUrls.length > 0) {
226 console.log(`[${key}] URLs already exist:\n ${existingUrls.join(',\n ')}`);
227 }
228
229 if (addedCount > 0) {
230 data += comment;
231 file = file.replace(comment, data);
232 fs.writeFileSync(path.resolve('./src/pages/playerUrls.js'), file);
233 console.log(`[${key}] Added ${addedCount} new URLs.`);
234 } else {
235 console.log(`[${key}] No new URLs added.`);
236 }
237}
238
239const URL_TYPES = {
240 PAGE: 'page',

Callers 3

voeFunction · 0.85
vidmolyFunction · 0.85
mixdropFunction · 0.85

Calls 1

logFoundUrlsFunction · 0.85

Tested by

no test coverage detected