1- import * as fs from 'fs' ;
2- import * as path from 'path' ;
1+ import { existsSync , mkdirSync , writeFileSync } from 'node: fs' ;
2+ import { dirname , join } from 'node: path' ;
33
44import * as templates from '../code/lib/cli-storybook/src/sandbox-templates' ;
55
@@ -31,7 +31,7 @@ const projectJson = (name: string, framework: string, tags: string[]) => ({
3131} ) ;
3232Object . entries ( allTemplates ) . forEach ( ( [ key , value ] ) => {
3333 const p = key . replaceAll ( '/' , '-' ) ;
34- const full = path . join ( process . cwd ( ) , '../code/sandbox' , p , 'project.json' ) ;
34+ const full = join ( process . cwd ( ) , '../code/sandbox' , p , 'project.json' ) ;
3535
3636 console . log ( full ) ;
3737 const framework = value . expected . framework . replace ( '@storybook/' , '' ) ;
@@ -44,7 +44,7 @@ Object.entries(allTemplates).forEach(([key, value]) => {
4444 ] ;
4545 ensureDirectoryExistence ( full ) ;
4646 console . log ( full ) ;
47- fs . writeFileSync (
47+ writeFileSync (
4848 full ,
4949 '// auto-generated from scripts/create-nx-sandbox-projects.ts\n' +
5050 JSON . stringify ( projectJson ( key , framework , tags ) , null , 2 ) ,
@@ -55,10 +55,10 @@ Object.entries(allTemplates).forEach(([key, value]) => {
5555} ) ;
5656
5757function ensureDirectoryExistence ( filePath : string ) : void {
58- const dirname = path . dirname ( filePath ) ;
59- if ( fs . existsSync ( dirname ) ) {
58+ const dir = dirname ( filePath ) ;
59+ if ( existsSync ( dir ) ) {
6060 return ;
6161 }
62- ensureDirectoryExistence ( dirname ) ;
63- fs . mkdirSync ( dirname ) ;
62+ ensureDirectoryExistence ( dir ) ;
63+ mkdirSync ( dir ) ;
6464}
0 commit comments