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

Function preBuildLoginDoneVersion

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

* Build "Login Done" page for the specified version. * @param {string} version * @return {Promise }

(version)

Source from the content-addressed store, hash-verified

343 * @return {Promise<void>}
344 */
345async function preBuildLoginDoneVersion(version) {
346 const srcDir = `extensions/amp-access/${version}`;
347 const buildDir = `build/all/amp-access-${version}`;
348 const htmlPath = `${srcDir}/amp-login-done.html`;
349 const jsPath = `${srcDir}/amp-login-done.js`;
350
351 // Build HTML.
352 const html = await fs.readFile(htmlPath, 'utf8');
353 const minJs = `https://${hostname}/v0/amp-login-done-${version}.js`;
354 const minHtml = html
355 .replace(`../../../dist/v0/amp-login-done-${version}.max.js`, minJs)
356 .replace(`../../../dist/v0/amp-login-done-${version}.js`, minJs);
357 if (minHtml.indexOf(minJs) == -1) {
358 throw new Error('Failed to correctly set JS in login-done.html');
359 }
360 await fs.outputFile(`dist/v0/amp-login-done-${version}.html`, minHtml);
361
362 // Build JS.
363 const js = await fs.readFile(jsPath, 'utf8');
364 const builtName = `amp-login-done-${version}.max.js`;
365 await fs.outputFile(`${buildDir}/${builtName}`, js);
366 const jsFiles = await fastGlob(`${srcDir}/*.js`);
367 await Promise.all(
368 jsFiles.map((jsFile) => {
369 return fs.copy(jsFile, `${buildDir}/${path.basename(jsFile)}`);
370 })
371 );
372}
373
374module.exports = {
375 dist,

Callers 1

preBuildLoginDoneFunction · 0.85

Calls 1

replaceMethod · 0.45

Tested by

no test coverage detected