Skip to content

Commit 8f19297

Browse files
committed
chore(docs): Fix alert sandboxes
1 parent 5d494bf commit 8f19297

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

packages/dev-utils/src/sandbox/createSandbox.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function getExtension(filePath: string): string {
3434
function transformFileContents(
3535
contents: string,
3636
filePath: string,
37-
demoName?: string
37+
isDemoFile = false
3838
): string {
3939
const parentFolders = filePath.replace("src/", "").split("/").length - 1;
4040

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

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

6263
return format(transformed);
@@ -169,7 +170,7 @@ export function createSandbox(
169170
content: transformFileContents(
170171
sourceFile.getFullText(),
171172
"src/Demo.tsx",
172-
demoName
173+
true
173174
),
174175
},
175176
};

0 commit comments

Comments
 (0)