@@ -2,11 +2,11 @@ import fs from 'node:fs';
22import path from 'node:path' ;
33import { fileURLToPath } from 'node:url' ;
44import { assert , beforeEach , expect , test } from '@rstest/core' ;
5- import { create } from '../dist/index.js ' ;
5+ import { create } from '../src ' ;
66
77const __dirname = path . dirname ( fileURLToPath ( import . meta. url ) ) ;
8- const testDir = path . join ( __dirname , 'temp' ) ;
98const fixturesDir = path . join ( __dirname , 'fixtures' , 'agents-md' ) ;
9+ const testDir = path . join ( fixturesDir , 'test-temp-output' ) ;
1010
1111beforeEach ( ( ) => {
1212 // Clean up test directory before each test
@@ -15,13 +15,8 @@ beforeEach(() => {
1515 }
1616 fs . mkdirSync ( testDir , { recursive : true } ) ;
1717
18- // Store original argv
19- const originalArgv = process . argv ;
20-
2118 // Return cleanup function
2219 return ( ) => {
23- // Restore original argv and clean up
24- process . argv = originalArgv ;
2520 if ( fs . existsSync ( testDir ) ) {
2621 fs . rmSync ( testDir , { recursive : true } ) ;
2722 }
@@ -30,13 +25,13 @@ beforeEach(() => {
3025
3126test ( 'should generate AGENTS.md with no tools selected' , async ( ) => {
3227 const projectDir = path . join ( testDir , 'no-tools' ) ;
33- process . argv = [ 'node' , 'test' , '--dir' , projectDir , '--template' , 'vanilla' ] ;
3428
3529 await create ( {
3630 name : 'test' ,
3731 root : fixturesDir ,
3832 templates : [ 'vanilla' ] ,
3933 getTemplateName : async ( ) => 'vanilla' ,
34+ argv : [ 'node' , 'test' , '--dir' , projectDir , '--template' , 'vanilla' ] ,
4035 } ) ;
4136
4237 const agentsPath = path . join ( projectDir , 'AGENTS.md' ) ;
@@ -75,22 +70,22 @@ test('should generate AGENTS.md with no tools selected', async () => {
7570
7671test ( 'should generate AGENTS.md with single tool selected' , async ( ) => {
7772 const projectDir = path . join ( testDir , 'single-tool' ) ;
78- process . argv = [
79- 'node' ,
80- 'test' ,
81- '--dir' ,
82- projectDir ,
83- '--template' ,
84- 'vanilla' ,
85- '--tools' ,
86- 'biome' ,
87- ] ;
8873
8974 await create ( {
9075 name : 'test' ,
9176 root : fixturesDir ,
9277 templates : [ 'vanilla' ] ,
9378 getTemplateName : async ( ) => 'vanilla' ,
79+ argv : [
80+ 'node' ,
81+ 'test' ,
82+ '--dir' ,
83+ projectDir ,
84+ '--template' ,
85+ 'vanilla' ,
86+ '--tools' ,
87+ 'biome' ,
88+ ] ,
9489 } ) ;
9590
9691 const agentsPath = path . join ( projectDir , 'AGENTS.md' ) ;
@@ -134,16 +129,6 @@ test('should generate AGENTS.md with single tool selected', async () => {
134129
135130test ( 'should generate AGENTS.md with eslint tool and template mapping' , async ( ) => {
136131 const projectDir = path . join ( testDir , 'eslint-tool' ) ;
137- process . argv = [
138- 'node' ,
139- 'test' ,
140- '--dir' ,
141- projectDir ,
142- '--template' ,
143- 'vanilla' ,
144- '--tools' ,
145- 'eslint' ,
146- ] ;
147132
148133 await create ( {
149134 name : 'test' ,
@@ -154,6 +139,16 @@ test('should generate AGENTS.md with eslint tool and template mapping', async ()
154139 if ( templateName === 'vanilla' ) return 'vanilla-ts' ;
155140 return null ;
156141 } ,
142+ argv : [
143+ 'node' ,
144+ 'test' ,
145+ '--dir' ,
146+ projectDir ,
147+ '--template' ,
148+ 'vanilla' ,
149+ '--tools' ,
150+ 'eslint' ,
151+ ] ,
157152 } ) ;
158153
159154 const agentsPath = path . join ( projectDir , 'AGENTS.md' ) ;
@@ -196,13 +191,13 @@ test('should generate AGENTS.md with eslint tool and template mapping', async ()
196191
197192test ( 'should merge top-level sections from AGENTS.md files' , async ( ) => {
198193 const projectDir = path . join ( testDir , 'h1-support' ) ;
199- process . argv = [ 'node' , 'test' , '--dir' , projectDir , '--template' , 'vanilla' ] ;
200194
201195 await create ( {
202196 name : 'test' ,
203197 root : fixturesDir ,
204198 templates : [ 'vanilla' ] ,
205199 getTemplateName : async ( ) => 'vanilla' ,
200+ argv : [ 'node' , 'test' , '--dir' , projectDir , '--template' , 'vanilla' ] ,
206201 } ) ;
207202
208203 const agentsPath = path . join ( projectDir , 'AGENTS.md' ) ;
0 commit comments