* Merge the files.txt files for the flavor's module/nomodule outputs. * @param {string} flavor
(flavor)
| 42 | * @param {string} flavor |
| 43 | */ |
| 44 | function mergeFilesTxt_(flavor) { |
| 45 | const /** @type Map<string, Set<string>> */ filesByRtv = new Map(); |
| 46 | |
| 47 | const filesTxtPaths = fastGlob.sync( |
| 48 | path.join(SRCS_DIR, flavor, '*/org-cdn/rtv/*/files.txt') |
| 49 | ); |
| 50 | for (const filesTxtPath of filesTxtPaths) { |
| 51 | // filesTxtPath is guaranteed to end with '/<15-digits-rtv>/files.txt', so |
| 52 | // we can extract the RTV with simple negative start/end indexes. |
| 53 | const rtv = filesTxtPath.slice(-25, -10); |
| 54 | if (!filesByRtv.has(rtv)) { |
| 55 | filesByRtv.set(rtv, new Set()); |
| 56 | } |
| 57 | |
| 58 | // Add all files in this module/nomodule directory's RTV to the set. |
| 59 | fs.readFileSync(filesTxtPath, {encoding: 'utf-8'}) |
| 60 | .trim() |
| 61 | .split('\n') |
| 62 | .forEach((file) => { |
| 63 | filesByRtv.get(rtv)?.add(file); |
| 64 | }); |
| 65 | } |
| 66 | |
| 67 | filesByRtv.forEach((files, rtv) => { |
| 68 | log('Writing merged', cyan('files.txt'), 'for RTV', cyan(rtv)); |
| 69 | fs.writeFileSync( |
| 70 | path.join(DEST_DIR, '/org-cdn/rtv', rtv, 'files.txt'), |
| 71 | [...files].sort().join('\n') |
| 72 | ); |
| 73 | }); |
| 74 | } |
| 75 | |
| 76 | let printProgressReady = true; |
| 77 |