update to not fail in offline mode

This commit is contained in:
2018-02-14 23:51:08 +01:00
parent 21100dbb32
commit 26c7b0c69a
9 changed files with 127 additions and 316 deletions

View File

@ -56,14 +56,23 @@ export class NpmRegistry {
plugins.beautylog.log(`Search on npm for ${plugins.beautycolor.coloredString(searchString, 'pink')}`)
let response = (await plugins.smartrequest.get(this.searchDomain + searchString, {}))
let body: any = response.body
let body: any;
try {
let response = (await plugins.smartrequest.get(this.searchDomain + searchString, {}))
body = response.body
} catch {
// we do nothing
}
// lets create the response
// lets create the packageArray
let packageArray: NpmPackage[] = []
if (typeof body === 'string') {
// if request failed just return it empty
if (!body || typeof body === 'string') {
return packageArray
}
for (let packageArg of body.results) {
let localPackage = new NpmPackage(packageArg.package)
packageArray.push(localPackage)

View File

@ -1,5 +1,3 @@
import 'typings-global'
import * as beautycolor from 'beautycolor'
import * as beautylog from 'beautylog'
import * as smartrequest from 'smartrequest'