From d71e61afa8da6b718e6bce6188dc631d3c1cf055 Mon Sep 17 00:00:00 2001 From: Favo Yang Date: Mon, 27 Jul 2020 01:30:50 +0800 Subject: [PATCH] fix: only fallback to old search when new search endpoint is unavailable --- bin/openupm | 0 lib/cmd-search.js | 8 +++++--- 2 files changed, 5 insertions(+), 3 deletions(-) mode change 100644 => 100755 bin/openupm diff --git a/bin/openupm b/bin/openupm old mode 100644 new mode 100755 diff --git a/lib/cmd-search.js b/lib/cmd-search.js index 8223dfd6..20bd4707 100644 --- a/lib/cmd-search.js +++ b/lib/cmd-search.js @@ -99,7 +99,7 @@ const searchOld = async function(keyword) { log.debug(`status ${err.response.status}`); if (isConnectionError(err)) log.error(`can not reach to registry ${env.registry}`); - else log.error(err.message); + else if (!is404Error(err)) log.error(err.message); } }; @@ -119,14 +119,16 @@ module.exports = async function(keyword, options) { // search endpoint let results = await searchEndpoint(keyword); // search old search - if (!results) results = (await searchOld(keyword)) || []; + if (results === undefined) { + results = (await searchOld(keyword)) || []; + } // search upstream // if (env.upstream) { // const upstreamResults = // (await searchEndpoint(keyword, env.upstreamRegistry)) || []; // results.push(...upstreamResults); // } - if (results.length) { + if (results && results.length) { results.forEach(x => table.push(x.slice(0, -1))); log.info(table.toString()); } else log.info(`No matches found for "${keyword}"`);