* post Build amp-web-push publisher files HTML page. * @return {Promise }
()
| 273 | * @return {Promise<void>} |
| 274 | */ |
| 275 | async 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. |
no test coverage detected