@eventcatalog/sdk 2.7.2 → 2.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -270,6 +270,7 @@ var rmResourceById = async (catalogDir, id, version, options) => {
270
270
  await Promise.all(
271
271
  matchedFiles.map(async (file) => {
272
272
  await fs.rm(file, { recursive: true });
273
+ await waitForFileRemoval(file);
273
274
  })
274
275
  );
275
276
  } else {
@@ -277,10 +278,22 @@ var rmResourceById = async (catalogDir, id, version, options) => {
277
278
  matchedFiles.map(async (file) => {
278
279
  const directory = dirname2(file);
279
280
  await fs.rm(directory, { recursive: true, force: true });
281
+ await waitForFileRemoval(directory);
280
282
  })
281
283
  );
282
284
  }
283
285
  };
286
+ var waitForFileRemoval = async (path5, maxRetries = 50, delay = 10) => {
287
+ for (let i = 0; i < maxRetries; i++) {
288
+ try {
289
+ await fs.access(path5);
290
+ await new Promise((resolve2) => setTimeout(resolve2, delay));
291
+ } catch (error) {
292
+ return;
293
+ }
294
+ }
295
+ throw new Error(`File/directory ${path5} was not removed after ${maxRetries} attempts`);
296
+ };
284
297
  var addFileToResource = async (catalogDir, id, file, version) => {
285
298
  const pathToResource = await findFileById(catalogDir, id, version);
286
299
  if (!pathToResource) throw new Error("Cannot find directory to write file to");