Skip to content

Commit

Permalink
fix(measure): fix port option (#192)
Browse files Browse the repository at this point in the history
When building the Flashlight CLI, for some reason the comment in the HTML file got removed
Actually it's unclear to me why it wasn't getting removed before, now at least we're sure that this will never get removed by parcel
  • Loading branch information
Almouro committed Jan 18, 2024
1 parent bd1f486 commit 1d8585f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ describe("ServerApp", () => {
});

beforeEach(() => {
(fs.promises.readFile as jest.Mock).mockResolvedValue("<html>/* %FLASHLIGHT_DATA% */</html>");
(fs.promises.readFile as jest.Mock).mockResolvedValue(
"<html><script>__FLASHLIGHT_DATA__;</script></html>"
);

app = createExpressApp(injected);
});
Expand All @@ -37,6 +39,6 @@ describe("ServerApp", () => {
test("index.html contains the FlashlightData placeholder", async () => {
const fsPromises = jest.requireActual("fs").promises;
const fileContent = await fsPromises.readFile(`${__dirname}/../../webapp/index.html`, "utf8");
expect(fileContent).toContain("/* %FLASHLIGHT_DATA% */");
expect(fileContent).toContain("__FLASHLIGHT_DATA__;");
});
});
2 changes: 1 addition & 1 deletion packages/commands/measure/src/server/ServerApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const createExpressApp = (injected: FlashlightData) => {
const indexHtml = path.join(pathToDist, "index.html");
let data = await fs.readFile(indexHtml, "utf8");
data = data.replace(
"/* %FLASHLIGHT_DATA% */",
"__FLASHLIGHT_DATA__;",
`window.__FLASHLIGHT_DATA__ = ${JSON.stringify(injected)};`
);
res.send(data);
Expand Down
2 changes: 1 addition & 1 deletion packages/commands/measure/src/webapp/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<div id="app"></div>
<script type="module" src="index.js"></script>
<script>
/* %FLASHLIGHT_DATA% */
__FLASHLIGHT_DATA__;
</script>
</body>
</html>

0 comments on commit 1d8585f

Please sign in to comment.