MCPcopy
hub / github.com/ampproject/amphtml / mergeFilesTxt_

Function mergeFilesTxt_

build-system/release-workflows/upload-release.js:44–74  ·  view source on GitHub ↗

* Merge the files.txt files for the flavor's module/nomodule outputs. * @param {string} flavor

(flavor)

Source from the content-addressed store, hash-verified

42 * @param {string} flavor
43 */
44function 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
76let printProgressReady = true;
77

Callers 1

upload-release.jsFile · 0.85

Calls 8

cyanFunction · 0.85
syncMethod · 0.80
logFunction · 0.50
hasMethod · 0.45
setMethod · 0.45
forEachMethod · 0.45
addMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected