Skip to content

Commit

Permalink
Remove code duplication in LavaMoat build script (#2564)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mrtenz authored Jul 10, 2024
1 parent 2b9ac55 commit 2132754
Showing 1 changed file with 17 additions and 24 deletions.
41 changes: 17 additions & 24 deletions packages/snaps-execution-environments/scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,30 +95,23 @@ async function main() {
JSON.stringify(lavamoatSecurityOptionsBrowser),
);

const htmlFile = `
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>MetaMask Snaps Execution Environment</title>
<script>${lavaMoatRuntimeBrowser}</script>
</head>
<body>
<script src="bundle.js"></script>
</body>
</html>`;

const createInlinedHTML = (bundleSource) => `<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>MetaMask Snaps Execution Environment</title>
<script>${lavaMoatRuntimeBrowser}</script>
</head>
<body>
<script>${bundleSource}</script>
</body>
</html>`;
const createHtml = (scriptTag) => `
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>MetaMask Snaps Execution Environment</title>
<script>${lavaMoatRuntimeBrowser}</script>
</head>
<body>
${scriptTag}
</body>
</html>`;

const htmlFile = createHtml('<script src="bundle.js"></script>');

const createInlinedHTML = (bundleSource) =>
createHtml(`<script>${bundleSource}</script>`);

await Promise.all(
Object.entries(ENTRY_POINTS).map(async ([key, config]) => {
Expand Down

0 comments on commit 2132754

Please sign in to comment.