@@ -197,9 +197,56 @@ lodash@^4.17.21:
197197 await writeFile ( join ( this . path , relativePath ) , content ) ;
198198 }
199199
200+ async waitForFileSystemSync ( ) {
201+ // In CI environments, add a small delay and verify file system state
202+ await new Promise ( ( resolve ) => setTimeout ( resolve , 100 ) ) ;
203+
204+ // Try to read the lockfile to ensure it's accessible and wait for it to stabilize
205+ let retries = 0 ;
206+ const maxRetries = 5 ;
207+ let lastContent = null ;
208+
209+ while ( retries < maxRetries ) {
210+ try {
211+ let lockfilePath ;
212+ if ( this . packageManager === "npm" ) {
213+ lockfilePath = join ( this . path , "package-lock.json" ) ;
214+ } else if ( this . packageManager === "yarn" ) {
215+ lockfilePath = join ( this . path , "yarn.lock" ) ;
216+ } else {
217+ lockfilePath = join ( this . path , "pnpm-lock.yaml" ) ;
218+ }
219+
220+ const content = await readFile ( lockfilePath , "utf8" ) ;
221+
222+ if ( lastContent === null ) {
223+ lastContent = content ;
224+ await new Promise ( ( resolve ) => setTimeout ( resolve , 50 ) ) ;
225+ retries ++ ;
226+ continue ;
227+ }
228+
229+ // Check if content has stabilized
230+ if ( content === lastContent ) {
231+ break ;
232+ }
233+
234+ lastContent = content ;
235+ await new Promise ( ( resolve ) => setTimeout ( resolve , 50 ) ) ;
236+ retries ++ ;
237+ } catch {
238+ // If we can't read the lockfile, wait a bit more
239+ await new Promise ( ( resolve ) => setTimeout ( resolve , 100 ) ) ;
240+ retries ++ ;
241+ }
242+ }
243+ }
244+
200245 async commitChanges ( message = "Test commit" ) {
201246 await this . runCommand ( "git" , [ "add" , "." ] ) ;
202247 await this . runCommand ( "git" , [ "commit" , "-m" , message ] ) ;
248+ // Ensure file system sync in CI environments
249+ await this . waitForFileSystemSync ( ) ;
203250 }
204251
205252 async setupHusky ( ) {
@@ -270,10 +317,14 @@ npx lint-staged
270317
271318 async createBranch ( branchName ) {
272319 await this . runCommand ( "git" , [ "checkout" , "-b" , branchName ] ) ;
320+ // Ensure file system sync in CI environments
321+ await this . waitForFileSystemSync ( ) ;
273322 }
274323
275324 async switchBranch ( branchName ) {
276325 await this . runCommand ( "git" , [ "checkout" , branchName ] ) ;
326+ // Ensure file system sync in CI environments
327+ await this . waitForFileSystemSync ( ) ;
277328 }
278329}
279330
0 commit comments