@orval/core 8.4.1 → 8.4.2

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
@@ -4444,7 +4444,8 @@ async function writeSplitTagsMode({ builder, output, projectName, header, needSc
4444
4444
  const mockOption = output.mock && !isFunction(output.mock) ? output.mock : void 0;
4445
4445
  const indexFilePath = mockOption?.indexMockFiles ? join(dirname$1, "index." + getMockFileExtensionByTypeName(mockOption) + extension) : void 0;
4446
4446
  if (indexFilePath) await fs$1.outputFile(indexFilePath, "");
4447
- const generatedFilePathsArray = await Promise.all(Object.entries(target).map(async ([tag, target$1]) => {
4447
+ const tagEntries = Object.entries(target);
4448
+ const generatedFilePathsArray = await Promise.all(tagEntries.map(async ([tag, target$1]) => {
4448
4449
  try {
4449
4450
  const { imports, implementation, implementationMock, importsMock, mutators, clientMutators, formData, fetchReviver, formUrlEncoded, paramsSerializer } = target$1;
4450
4451
  let implementationData = header;
@@ -4517,13 +4518,7 @@ async function writeSplitTagsMode({ builder, output, projectName, header, needSc
4517
4518
  const implementationPath = join(dirname$1, tag, implementationFilename);
4518
4519
  await fs$1.outputFile(implementationPath, implementationData);
4519
4520
  const mockPath = output.mock ? join(dirname$1, tag, tag + "." + getMockFileExtensionByTypeName(output.mock) + extension) : void 0;
4520
- if (mockPath) {
4521
- await fs$1.outputFile(mockPath, mockData);
4522
- if (indexFilePath && mockOption) {
4523
- const localMockPath = joinSafe("./", tag, tag + "." + getMockFileExtensionByTypeName(mockOption));
4524
- await fs$1.appendFile(indexFilePath, `export { get${pascal(tag)}Mock } from '${localMockPath}'\n`);
4525
- }
4526
- }
4521
+ if (mockPath) await fs$1.outputFile(mockPath, mockData);
4527
4522
  return [
4528
4523
  implementationPath,
4529
4524
  ...schemasPath ? [schemasPath] : [],
@@ -4533,6 +4528,13 @@ async function writeSplitTagsMode({ builder, output, projectName, header, needSc
4533
4528
  throw new Error(`Oups... 🍻. An Error occurred while splitting tag ${tag} => ${String(error)}`);
4534
4529
  }
4535
4530
  }));
4531
+ if (indexFilePath && mockOption) {
4532
+ const indexContent = tagEntries.map(([tag]) => {
4533
+ const localMockPath = joinSafe("./", tag, tag + "." + getMockFileExtensionByTypeName(mockOption));
4534
+ return `export { get${pascal(tag)}Mock } from '${localMockPath}'\n`;
4535
+ }).join("");
4536
+ await fs$1.appendFile(indexFilePath, indexContent);
4537
+ }
4536
4538
  return [...indexFilePath ? [indexFilePath] : [], ...generatedFilePathsArray.flat()];
4537
4539
  }
4538
4540