More fixes in fetching tool versions

This commit is contained in:
Shivam Mathur
2021-07-12 17:00:40 +05:30
parent f31bef6a30
commit 09e08a3554
10 changed files with 285 additions and 302 deletions

View File

@ -264,41 +264,6 @@ export async function writeScript(
return script_path;
}
/**
* Function to get information about a tool
*
* @param tool
*/
export async function getToolData(
tool: string
): Promise<Record<string, string>> {
const tools_json: string = await readFile('tools.json', 'src/configs');
const json_data: Record<string, Record<string, string>> =
JSON.parse(tools_json);
let tool_data: Record<string, string>;
const tools: string[] = Object.keys(json_data);
if (tools.includes(tool)) {
tool_data = json_data[tool];
tool_data['tool'] = tool;
} else {
const tool_key: string | undefined = Object.keys(json_data).find(
(key: string) => {
return (
json_data[key]['alias'] == tool ||
json_data[key]['repository'] == tool
);
}
);
if (tool_key) {
tool_data = json_data[tool_key];
tool_data['tool'] = tool_key;
} else {
tool_data = {tool: tool};
}
}
return tool_data;
}
/**
* Function to break extension csv into an array
*