11import fs from 'node:fs' ;
22import path from 'node:path' ;
33import { fileURLToPath } from 'node:url' ;
4- import { expect , test } from '@rstest/core' ;
4+ import { beforeEach , expect , test } from '@rstest/core' ;
55import { create } from '../src' ;
66
77const __dirname = path . dirname ( fileURLToPath ( import . meta. url ) ) ;
8- const fixturesDir = path . join ( __dirname , 'fixtures' , 'agents-md ' ) ;
8+ const fixturesDir = path . join ( __dirname , 'fixtures' , 'cli ' ) ;
99const testDir = path . join ( fixturesDir , 'test-temp-output' ) ;
1010
11+ beforeEach ( ( ) => {
12+ // Clean up test directory before each test
13+ if ( fs . existsSync ( testDir ) ) {
14+ fs . rmSync ( testDir , { recursive : true } ) ;
15+ }
16+ fs . mkdirSync ( testDir , { recursive : true } ) ;
17+
18+ // Return cleanup function
19+ return ( ) => {
20+ if ( fs . existsSync ( testDir ) ) {
21+ fs . rmSync ( testDir , { recursive : true } ) ;
22+ }
23+ } ;
24+ } ) ;
25+
1126test ( 'should accept comma separated tools option' , async ( ) => {
1227 const projectDir = path . join ( testDir , 'comma-separated-tools' ) ;
1328
@@ -31,3 +46,27 @@ test('should accept comma separated tools option', async () => {
3146 expect ( fs . existsSync ( path . join ( projectDir , 'eslint.config.mjs' ) ) ) . toBe ( true ) ;
3247 expect ( fs . existsSync ( path . join ( projectDir , '.prettierrc' ) ) ) . toBe ( true ) ;
3348} ) ;
49+
50+ test ( 'should skip tools selection' , async ( ) => {
51+ const projectDir = path . join ( testDir , 'comma-separated-tools' ) ;
52+
53+ await create ( {
54+ name : 'test' ,
55+ root : fixturesDir ,
56+ templates : [ 'vanilla' ] ,
57+ getTemplateName : async ( ) => 'vanilla' ,
58+ argv : [
59+ 'node' ,
60+ 'test' ,
61+ '--dir' ,
62+ projectDir ,
63+ '--template' ,
64+ 'vanilla' ,
65+ '--tools' ,
66+ '""' ,
67+ ] ,
68+ } ) ;
69+
70+ expect ( fs . existsSync ( path . join ( projectDir , 'eslint.config.mjs' ) ) ) . toBe ( false ) ;
71+ expect ( fs . existsSync ( path . join ( projectDir , '.prettierrc' ) ) ) . toBe ( false ) ;
72+ } ) ;
0 commit comments