@eventcatalog/sdk 2.7.1 → 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.
package/dist/index.mjs CHANGED
@@ -266,6 +266,7 @@ var rmResourceById = async (catalogDir, id, version, options) => {
266
266
  await Promise.all(
267
267
  matchedFiles.map(async (file) => {
268
268
  await fs.rm(file, { recursive: true });
269
+ await waitForFileRemoval(file);
269
270
  })
270
271
  );
271
272
  } else {
@@ -273,10 +274,22 @@ var rmResourceById = async (catalogDir, id, version, options) => {
273
274
  matchedFiles.map(async (file) => {
274
275
  const directory = dirname2(file);
275
276
  await fs.rm(directory, { recursive: true, force: true });
277
+ await waitForFileRemoval(directory);
276
278
  })
277
279
  );
278
280
  }
279
281
  };
282
+ var waitForFileRemoval = async (path5, maxRetries = 50, delay = 10) => {
283
+ for (let i = 0; i < maxRetries; i++) {
284
+ try {
285
+ await fs.access(path5);
286
+ await new Promise((resolve2) => setTimeout(resolve2, delay));
287
+ } catch (error) {
288
+ return;
289
+ }
290
+ }
291
+ throw new Error(`File/directory ${path5} was not removed after ${maxRetries} attempts`);
292
+ };
280
293
  var addFileToResource = async (catalogDir, id, file, version) => {
281
294
  const pathToResource = await findFileById(catalogDir, id, version);
282
295
  if (!pathToResource) throw new Error("Cannot find directory to write file to");
@@ -449,7 +462,9 @@ var versionService = (directory) => async (id) => versionResource(directory, id)
449
462
  var rmService = (directory) => async (path5) => {
450
463
  await fs5.rm(join6(directory, path5), { recursive: true });
451
464
  };
452
- var rmServiceById = (directory) => async (id, version, persistFiles) => rmResourceById(directory, id, version, { type: "service", persistFiles });
465
+ var rmServiceById = (directory) => async (id, version, persistFiles) => {
466
+ await rmResourceById(directory, id, version, { type: "service", persistFiles });
467
+ };
453
468
  var addFileToService = (directory) => async (id, file, version) => addFileToResource(directory, id, file, version);
454
469
  var getSpecificationFilesForService = (directory) => async (id, version) => {
455
470
  let service = await getService(directory)(id, version);