Skip to content

Commit

Permalink
fix: only fallback to old search when new search endpoint is unavailable
Browse files Browse the repository at this point in the history
  • Loading branch information
favoyang committed Jul 26, 2020
1 parent 93b0577 commit d71e61a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Empty file modified bin/openupm
100644 → 100755
Empty file.
8 changes: 5 additions & 3 deletions lib/cmd-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
};

Expand All @@ -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}"`);
Expand Down

0 comments on commit d71e61a

Please sign in to comment.