Skip to content

Commit

Permalink
fef
Browse files Browse the repository at this point in the history
  • Loading branch information
vishvamsinh28 committed Nov 5, 2024
1 parent 771c5db commit 2be6d42
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions scripts/tools/tools-object.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,14 @@ async function convertTools(data) {
let toolObject = await createToolObject(jsonToolFileContent, repositoryUrl, repoDescription, isAsyncAPIrepo);

// Tool Object is appended to each category array according to Fuse search for categories inside Tool Object
jsonToolFileContent.filters.categories.forEach(async (category) => {
await Promise.all(jsonToolFileContent.filters.categories.map(async (category) => {
const categorySearch = await fuse.search(category);

if (categorySearch.length) {
let searchedCategoryName = categorySearch[0].item.name
if (!finalToolsObject[searchedCategoryName].toolsList.find((element => element === toolObject)))
finalToolsObject[searchedCategoryName].toolsList.push(toolObject);
} else {
// if Tool object has a category, not defined in our categorylist, then this provides a `other` category to the tool.
if (!finalToolsObject['Others'].toolsList.find((element => element === toolObject)))
finalToolsObject['Others'].toolsList.push(toolObject);
const targetCategory = categorySearch.length ? categorySearch[0].item.name : 'Others';
const toolsList = finalToolsObject[targetCategory].toolsList;
if (!toolsList.includes(toolObject)) {
toolsList.push(toolObject);
}
});
}));
} else {
console.error('Script is not failing, it is just dropping errors for further investigation');
console.error('Invalid .asyncapi-tool file.');
Expand Down

0 comments on commit 2be6d42

Please sign in to comment.