File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed
packages/dev-utils/src/sandbox Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ function getExtension(filePath: string): string {
3434function 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 ( / \. ( \. \/ T e x t F i e l d T h e m e C o n f i g ) / , "$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+ / e x p o r t d e f a u l t f u n c t i o n [ A - Z ] [ A - z 0 - 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 } ;
You can’t perform that action at this time.
0 commit comments