@@ -10,15 +10,17 @@ describe('Integration Ecosystem & Plugin Architecture', () => {
10
10
let mockContext : SetupContext
11
11
let originalEnv : Record < string , string | undefined >
12
12
let originalCwd : string
13
+ let tempDir : string
13
14
14
15
beforeEach ( ( ) => {
15
16
// Store original working directory
16
17
originalCwd = process . cwd ( )
17
-
18
+
18
19
// Change to a temporary directory to avoid interference with project files
19
- const tempDir = fs . mkdtempSync ( path . join ( require ( 'node:os' ) . tmpdir ( ) , 'plugin-test-' ) )
20
+ // eslint-disable-next-line ts/no-require-imports
21
+ tempDir = fs . mkdtempSync ( path . join ( require ( 'node:os' ) . tmpdir ( ) , 'plugin-test-' ) )
20
22
process . chdir ( tempDir )
21
-
23
+
22
24
pluginManager = new PluginManager ( )
23
25
mockContext = {
24
26
step : 'setup_complete' ,
@@ -93,13 +95,13 @@ describe('Integration Ecosystem & Plugin Architecture', () => {
93
95
fs . rmSync ( file , { force : true } )
94
96
}
95
97
} )
96
-
98
+
97
99
// Restore original working directory and clean up temp directory
98
- const tempDir = process . cwd ( )
99
100
process . chdir ( originalCwd )
100
101
try {
101
102
fs . rmSync ( tempDir , { recursive : true , force : true } )
102
- } catch {
103
+ }
104
+ catch {
103
105
// Ignore cleanup errors
104
106
}
105
107
@@ -266,7 +268,20 @@ describe('Integration Ecosystem & Plugin Architecture', () => {
266
268
}
267
269
268
270
const customPluginPath = path . join ( '.buddy/plugins' , 'custom.json' )
269
- fs . writeFileSync ( customPluginPath , JSON . stringify ( customPlugin ) )
271
+
272
+ // Ensure no composer.json exists in the test directory
273
+ const composerPath = path . join ( process . cwd ( ) , 'composer.json' )
274
+ if ( fs . existsSync ( composerPath ) ) {
275
+ fs . rmSync ( composerPath , { force : true } )
276
+ }
277
+
278
+ // Write the file and ensure it's synced
279
+ const pluginContent = JSON . stringify ( customPlugin )
280
+ fs . writeFileSync ( customPluginPath , pluginContent )
281
+ fs . fsyncSync ( fs . openSync ( customPluginPath , 'r' ) )
282
+
283
+ // Small delay to ensure file system operations complete
284
+ await new Promise ( resolve => setTimeout ( resolve , 10 ) )
270
285
271
286
// Verify the file was written correctly
272
287
expect ( fs . existsSync ( customPluginPath ) ) . toBe ( true )
0 commit comments