mirror of
https://github.com/shivammathur/setup-php.git
synced 2025-11-25 08:38:38 +07:00
More fixes in fetching tool versions
This commit is contained in:
35
src/utils.ts
35
src/utils.ts
@ -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
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user