From 8c45327094b2560f7b5c813a1c1925920bd46038 Mon Sep 17 00:00:00 2001 From: Evo <85353424+EvolutionX-10@users.noreply.github.com> Date: Wed, 22 Jun 2022 22:23:42 +0530 Subject: [PATCH] fix: avoid crashing of cli when no plugin found (#47) --- src/prompts/plugin.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/prompts/plugin.js b/src/prompts/plugin.js index 4dec2ac..d9b1e36 100644 --- a/src/prompts/plugin.js +++ b/src/prompts/plugin.js @@ -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; }