@@ -64,7 +64,7 @@ function runCommand(command, args, options = {}) {
6464
6565 if ( result . status !== 0 ) {
6666 throw new Error (
67- `Command failed: ${ command } ${ args . join ( ' ' ) } (status ${ result . status ?? 1 } ${ result . signal ? `, signal ${ result . signal } ` : '' } )` ,
67+ `Command failed: ${ command } ${ args . join ( ' ' ) } (status ${ result . status ?? 1 } ${ result . signal ? `, signal ${ result . signal } ` : '' } )`
6868 ) ;
6969 }
7070}
@@ -191,10 +191,7 @@ function upsertHeadStyle(html, markerAttribute, styleTag) {
191191
192192function applySeoDirectivesToHtml (
193193 html ,
194- {
195- canonicalUrl = ROOT_CANONICAL_URL ,
196- robotsDirectives = TESTENV_ROBOTS_DIRECTIVES ,
197- } = { } ,
194+ { canonicalUrl = ROOT_CANONICAL_URL , robotsDirectives = TESTENV_ROBOTS_DIRECTIVES } = { }
198195) {
199196 let nextHtml = html ;
200197
@@ -495,13 +492,22 @@ const TESTENV_HIDE_HEADER_STYLE = `
495492 }
496493 </style>` ;
497494
495+ function hideTopHeaderInBuiltHtml ( html ) {
496+ if ( html . includes ( 'data-testenv-hide-header' ) ) {
497+ return html ;
498+ }
499+
500+ return html . replace ( '</head>' , `${ TESTENV_HIDE_HEADER_STYLE } \n </head>` ) ;
501+ }
502+
498503async function hideTopHeaderInBuiltPage ( pagePath ) {
499504 const html = await readFile ( pagePath , 'utf8' ) ;
500- if ( html . includes ( 'data-testenv-hide-header' ) ) {
505+ const nextHtml = hideTopHeaderInBuiltHtml ( html ) ;
506+
507+ if ( nextHtml === html ) {
501508 return ;
502509 }
503510
504- const nextHtml = html . replace ( '</head>' , `${ TESTENV_HIDE_HEADER_STYLE } \n </head>` ) ;
505511 await writeFile ( pagePath , nextHtml , 'utf8' ) ;
506512}
507513
@@ -541,11 +547,7 @@ async function createTemporaryDocsAppPlaceholder() {
541547}
542548
543549async function removeTemporaryDocsAppPlaceholder ( ) {
544- await writeFile (
545- docsAppPlaceholderPath ,
546- '<p>This will be overwritten during the npm build.</p>' ,
547- 'utf8' ,
548- ) ;
550+ await writeFile ( docsAppPlaceholderPath , '<p>This will be overwritten during the npm build.</p>' , 'utf8' ) ;
549551}
550552
551553async function main ( ) {
@@ -578,26 +580,19 @@ async function main() {
578580 await createTemporaryDocsAppPlaceholder ( ) ;
579581
580582 try {
581- runCommand (
582- 'pnpm' ,
583- [ '--dir' , 'docs-src' , 'exec' , 'docusaurus' , 'build' , '--out-dir' , '../testenv/site' ] ,
584- {
585- env : {
586- DOCS_BASE_URL : fullSiteBaseUrl ,
587- DOCS_SITE_URL : 'https://eviltester.github.io' ,
588- DOCS_TEST_BUILD : 'true' ,
589- DOCS_TEST_CANONICAL_SITE_URL : TESTENV_CANONICAL_SITE_URL ,
590- } ,
583+ runCommand ( 'pnpm' , [ '--dir' , 'docs-src' , 'exec' , 'docusaurus' , 'build' , '--out-dir' , '../testenv/site' ] , {
584+ env : {
585+ DOCS_BASE_URL : fullSiteBaseUrl ,
586+ DOCS_SITE_URL : 'https://eviltester.github.io' ,
587+ DOCS_TEST_BUILD : 'true' ,
588+ DOCS_TEST_CANONICAL_SITE_URL : TESTENV_CANONICAL_SITE_URL ,
591589 } ,
592- ) ;
590+ } ) ;
593591 } finally {
594592 await removeTemporaryDocsAppPlaceholder ( ) ;
595593 }
596594
597595 await copyWebBuildIntoDirectory ( tempWebDir , fullSiteDir ) ;
598- await hideTopHeaderInBuiltPage ( path . join ( fullSiteDir , 'app.html' ) ) ;
599- await hideTopHeaderInBuiltPage ( path . join ( fullSiteDir , 'generator.html' ) ) ;
600- await hideTopHeaderInBuiltPage ( path . join ( fullSiteDir , 'combinatorial.html' ) ) ;
601596 await rm ( tempWebDir , {
602597 recursive : true ,
603598 force : true ,
@@ -627,6 +622,7 @@ export {
627622 createLlmsTxt ,
628623 createSiteRobotsTxt ,
629624 createTestenvRobotsTxt ,
625+ hideTopHeaderInBuiltHtml ,
630626 renderIndexPage ,
631627} ;
632628
0 commit comments