Skip to content

Commit 77d51a7

Browse files
committed
test: write pre-rendered univeral html file to bazel bin dir
Server side rendered kitchen sync app was written inside the test sandbox execution directory, which is deleted after test execution when the is executed without `--sandbox_debug` option thus we couldn't retrieve the `index-prendered.html` file using the command `echo $(bazel info bazel-bin)/src/universal-app/index-prerendered.html`
1 parent 6e1f522 commit 77d51a7

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/universal-app/prerender.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import 'zone.js';
33

44
import {renderModuleFactory} from '@angular/platform-server';
55
import {readFileSync, writeFileSync} from 'fs';
6-
import {join} from 'path';
6+
import {dirname, join} from 'path';
77

88
import {KitchenSinkRootServerModuleNgFactory} from './kitchen-sink-root.ngfactory';
99

@@ -16,10 +16,12 @@ const indexHtmlPath = require.resolve('./index.html');
1616
const result = renderModuleFactory(
1717
KitchenSinkRootServerModuleNgFactory,
1818
{document: readFileSync(indexHtmlPath, 'utf-8')});
19+
const runfilesDir = process.env.RUNFILES_DIR as string;
20+
const bazelOutDir = dirname(runfilesDir.replace(/sandbox\/[a-z0-9]+-sandbox\/[0-9]+\//, ''));
1921

2022
result
2123
.then(content => {
22-
const filename = join(__dirname, 'index-prerendered.html');
24+
const filename = join(bazelOutDir, 'index-prerendered.html');
2325

2426
console.log('Inspect pre-rendered page here:');
2527
console.log(`file://${filename}`);

0 commit comments

Comments
 (0)