MCPcopy Index your code
hub / github.com/ampproject/amphtml / postBuildWebPushPublisherFilesVersion

Function postBuildWebPushPublisherFilesVersion

build-system/tasks/dist.js:275–296  ·  view source on GitHub ↗

* post Build amp-web-push publisher files HTML page. * @return {Promise }

()

Source from the content-addressed store, hash-verified

273 * @return {Promise<void>}
274 */
275async function postBuildWebPushPublisherFilesVersion() {
276 const distDir = 'dist/v0';
277 for (const version of WEB_PUSH_PUBLISHER_VERSIONS) {
278 const basePath = `extensions/amp-web-push/${version}`;
279 for (const fileName of WEB_PUSH_PUBLISHER_FILES) {
280 const minifiedName = maybeToEsmName(`${fileName}.js`);
281 const minifiedFile = `${distDir}/${minifiedName}`;
282 if (!fs.existsSync(minifiedFile)) {
283 throw new Error(`Cannot find ${minifiedFile}`);
284 }
285
286 // Build Helper Frame HTML
287 const html = await fs.readFile(`${basePath}/${fileName}.html`, 'utf8');
288 const js = await fs.readFile(minifiedFile, 'utf8');
289 const minifiedHtml = html.replace(
290 `<!-- [REPLACE-SENTINEL ${fileName}.js] -->`,
291 `<script>${js}</script>`
292 );
293 await fs.outputFile(`dist/v0/${fileName}.html`, minifiedHtml);
294 }
295 }
296}
297
298/**
299 * Precompilation steps required to build experiment js binaries.

Callers 1

Calls 2

maybeToEsmNameFunction · 0.85
replaceMethod · 0.45

Tested by

no test coverage detected