(page, urls)
| 126 | } |
| 127 | |
| 128 | function addPageUrls(page, urls) { |
| 129 | logFoundUrls(page, urls, URL_TYPES.PAGE); |
| 130 | |
| 131 | let file = JSON.parse(fs.readFileSync(path.resolve(`./src/pages/${page}/meta.json`), 'utf8')); |
| 132 | |
| 133 | let addedCount = 0; |
| 134 | const existingUrls = []; |
| 135 | for (const url of urls) { |
| 136 | if (!file.urls.match.includes(url)) { |
| 137 | file.urls.match.push(url); |
| 138 | addedCount++; |
| 139 | } else { |
| 140 | existingUrls.push(url); |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | if (existingUrls.length > 0) { |
| 145 | console.log(`[${page}] URLs already exist:\n ${existingUrls.join(',\n ')}`); |
| 146 | } |
| 147 | |
| 148 | if (addedCount > 0) { |
| 149 | fs.writeFileSync( |
| 150 | path.resolve(`./src/pages/${page}/meta.json`), |
| 151 | JSON.stringify(file, null, 2) + '\n', |
| 152 | ); |
| 153 | console.log(`[${page}] Added ${addedCount} new URLs.`); |
| 154 | } else { |
| 155 | console.log(`[${page}] No new URLs added.`); |
| 156 | } |
| 157 | } |
| 158 | |
| 159 | function addChibiUrls(page, urls, mainName = 'main.ts') { |
| 160 | logFoundUrls(page, urls, URL_TYPES.CHIBI); |
no test coverage detected