Don't print out a stacktrace when a package is not on NPM. (#13342)

This commit is contained in:
Andy 2016-12-27 18:36:22 -05:00 committed by GitHub
parent 3a73c98ef7
commit 50f1ae86af
2 changed files with 4 additions and 4 deletions

View File

@ -49,7 +49,7 @@ function getIndex() {
let version = "x.x";
let project = "https://github.com/baz/foo (Does not have to be to GitHub, but prefer linking to a source code repository rather than to a project website.)";
try {
const reg = yield loadString(`http://registry.npmjs.org/${newPackageName}`).then(JSON.parse);
const reg = JSON.parse(yield loadString(`http://registry.npmjs.org/${newPackageName}`));
const { latest } = reg["dist-tags"];
const { homepage } = reg.versions[latest];
version = latest.split(".").slice(0, 2).join(".");
@ -57,7 +57,7 @@ function getIndex() {
project = homepage;
}
catch (e) {
console.warn(`Could not retrieve version/homepage information: ${e.stack}`);
console.warn(`Warning: could not retrieve version/homepage information: ${e.message}`);
}
return `// Type definitions for ${newPackageName} ${version}
// Project: ${project}

View File

@ -55,7 +55,7 @@ async function getIndex() {
let version = "x.x"
let project = "https://github.com/baz/foo (Does not have to be to GitHub, but prefer linking to a source code repository rather than to a project website.)"
try {
const reg: Registry = await loadString(`http://registry.npmjs.org/${newPackageName}`).then(JSON.parse)
const reg: Registry = JSON.parse(await loadString(`http://registry.npmjs.org/${newPackageName}`))
const { latest } = reg["dist-tags"]
const { homepage } = reg.versions[latest]
@ -63,7 +63,7 @@ async function getIndex() {
version = latest.split(".").slice(0, 2).join(".")
if (homepage !== undefined) project = homepage
} catch (e) {
console.warn(`Could not retrieve version/homepage information: ${e.stack}`)
console.warn(`Warning: could not retrieve version/homepage information: ${e.message}`)
}
return `// Type definitions for ${newPackageName} ${version}