Skip to content

Commit

Permalink
chore(docs): Fix alert sandboxes
Browse files Browse the repository at this point in the history
  • Loading branch information
mlaursen committed Oct 20, 2021
1 parent 5d494bf commit 8f19297
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions packages/dev-utils/src/sandbox/createSandbox.ts
Expand Up @@ -34,7 +34,7 @@ function getExtension(filePath: string): string {
function transformFileContents(
contents: string,
filePath: string,
demoName?: string
isDemoFile = false
): string {
const parentFolders = filePath.replace("src/", "").split("/").length - 1;

Expand All @@ -53,10 +53,11 @@ function transformFileContents(
.replace(/\.(\.\/TextFieldThemeConfig)/, "$1")
.replace(aliasRegExp, `"${aliasReplacement}`);

if (demoName) {
transformed = transformed
.replace(`default function ${demoName}`, "default function Demo")
.replace(new RegExp(`<${demoName}(\\s+)`, "g"), "<Demo$1");
if (isDemoFile) {
transformed = transformed.replace(
/export default function [A-Z][A-z0-9]+\(/,
"export default function Demo("
);
}

return format(transformed);
Expand Down Expand Up @@ -169,7 +170,7 @@ export function createSandbox(
content: transformFileContents(
sourceFile.getFullText(),
"src/Demo.tsx",
demoName
true
),
},
};
Expand Down

0 comments on commit 8f19297

Please sign in to comment.