11import { join } from 'node:path'
22import type { ExecaSyncReturnValue , SyncOptions } from 'execa'
33import { execaCommandSync } from 'execa'
4- import { mkdirpSync , readdirSync , remove , writeFileSync } from 'fs-extra'
4+ import fs from 'fs-extra'
55import { afterEach , beforeAll , expect , test } from 'vitest'
66
77const CLI_PATH = join ( __dirname , '..' )
@@ -19,29 +19,30 @@ const run = (
1919// Helper to create a non-empty directory
2020const createNonEmptyDir = ( ) => {
2121 // Create the temporary directory
22- mkdirpSync ( genPath )
22+ fs . mkdirpSync ( genPath )
2323
2424 // Create a package.json file
2525 const pkgJson = join ( genPath , 'package.json' )
26- writeFileSync ( pkgJson , '{ "foo": "bar" }' )
26+ fs . writeFileSync ( pkgJson , '{ "foo": "bar" }' )
2727}
2828
2929// Vue 3 starter template
30- const templateFiles = readdirSync ( join ( CLI_PATH , 'template-vue' ) )
30+ const templateFiles = fs
31+ . readdirSync ( join ( CLI_PATH , 'template-vue' ) )
3132 // _gitignore is renamed to .gitignore
3233 . map ( ( filePath ) => ( filePath === '_gitignore' ? '.gitignore' : filePath ) )
3334 . sort ( )
3435
35- beforeAll ( ( ) => remove ( genPath ) )
36- afterEach ( ( ) => remove ( genPath ) )
36+ beforeAll ( ( ) => fs . remove ( genPath ) )
37+ afterEach ( ( ) => fs . remove ( genPath ) )
3738
3839test ( 'prompts for the project name if none supplied' , ( ) => {
3940 const { stdout } = run ( [ ] )
4041 expect ( stdout ) . toContain ( 'Project name:' )
4142} )
4243
4344test ( 'prompts for the framework if none supplied when target dir is current directory' , ( ) => {
44- mkdirpSync ( genPath )
45+ fs . mkdirpSync ( genPath )
4546 const { stdout } = run ( [ '.' ] , { cwd : genPath } )
4647 expect ( stdout ) . toContain ( 'Select a framework:' )
4748} )
@@ -79,7 +80,7 @@ test('successfully scaffolds a project based on vue starter template', () => {
7980 const { stdout } = run ( [ projectName , '--template' , 'vue' ] , {
8081 cwd : __dirname ,
8182 } )
82- const generatedFiles = readdirSync ( genPath ) . sort ( )
83+ const generatedFiles = fs . readdirSync ( genPath ) . sort ( )
8384
8485 // Assertions
8586 expect ( stdout ) . toContain ( `Scaffolding project in ${ genPath } ` )
@@ -90,7 +91,7 @@ test('works with the -t alias', () => {
9091 const { stdout } = run ( [ projectName , '-t' , 'vue' ] , {
9192 cwd : __dirname ,
9293 } )
93- const generatedFiles = readdirSync ( genPath ) . sort ( )
94+ const generatedFiles = fs . readdirSync ( genPath ) . sort ( )
9495
9596 // Assertions
9697 expect ( stdout ) . toContain ( `Scaffolding project in ${ genPath } ` )
0 commit comments