Skip to content

Commit

Permalink
#177: fix issue with naming collision when processing zips
Browse files Browse the repository at this point in the history
  • Loading branch information
mohit-s96 committed Sep 26, 2024
1 parent 3e188d7 commit 942205c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/schema/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ const processFiles = async ({ inputPath, fileContentsMap }, fileNamePrefix = 1)
const fileName = path.basename(inputPath);
const contents = await processFile({ filePath: inputPath });
if (fileName.endsWith('.zip')) {
const parsedContents = {};
Object.keys(contents).forEach(file => {
contents[addPrefixToFileName(file, fileNamePrefix++)] = JSON.parse(contents[file]);
parsedContents[addPrefixToFileName(file, fileNamePrefix++)] = JSON.parse(contents[file]);
});
Object.assign(fileContentsMap, contents);
Object.assign(fileContentsMap, parsedContents);
} else {
fileContentsMap[addPrefixToFileName(fileName, fileNamePrefix++)] = contents;
}
Expand All @@ -42,10 +43,11 @@ const processFiles = async ({ inputPath, fileContentsMap }, fileNamePrefix = 1)
filePath: path.join(inputPath, file)
});
if (fileName.endsWith('.zip')) {
const parsedContents = {};
Object.keys(content).forEach(file => {
content[addPrefixToFileName(file, fileNamePrefix++)] = JSON.parse(content[file]);
parsedContents[addPrefixToFileName(file, fileNamePrefix++)] = JSON.parse(content[file]);
});
Object.assign(fileContentsMap, content);
Object.assign(fileContentsMap, parsedContents);
} else {
fileContentsMap[addPrefixToFileName(fileName, fileNamePrefix++)] = content;
}
Expand Down

0 comments on commit 942205c

Please sign in to comment.