fix: avoid crashing of cli when no plugin found (#47)

This commit is contained in:
Evo
2022-06-22 22:23:42 +05:30
committed by GitHub
parent 361e6451a7
commit 8c45327094

View File

@@ -5,11 +5,15 @@ async function gimmechoices() {
(await getLang()) === 'typescript' ? 'TypeScript' : 'JavaScript';
const link = `https://api.github.com/repos/sern-handler/awesome-plugins/contents/${lang}`;
const data = (await axios.get(link)).data;
const choices = data.map((e) => ({
title: e.name,
value: e.download_url,
}));
const resp = await axios.default.get(link).catch(() => null);
if (!resp) return { title: 'No plugins found!', value: '', disabled: true };
const { data } = resp;
const choices = data.map(
(/** @type {{ name: string; download_url: string; }} */ e) => ({
title: e.name,
value: e.download_url,
})
);
return choices;
}