diff --git a/is-vulnerable.js b/is-vulnerable.js index 22a8600..17bc3be 100644 --- a/is-vulnerable.js +++ b/is-vulnerable.js @@ -33,7 +33,7 @@ async function fetchCoreIndex () { await new Promise((resolve) => { request(CORE_RAW_URL, (res) => { if (res.statusCode !== 200) { - console.error('Request to Github failed. Aborting...') + console.error(`Request to Github returned http status ${res.statusCode}. Aborting...`) process.nextTick(() => { process.exit(1) }) } @@ -46,10 +46,13 @@ async function fetchCoreIndex () { }) fileStream.on('error', (err) => { - console.error(`Error while writing to file '${coreLocalFile}'`, err.message) + console.error(`Error ${err.message} while writing to '${coreLocalFile}'. Aborting...`) process.nextTick(() => { process.exit(1) }) }) - }) + }).on('error', (err) => { + console.error(`Request to Github returned error ${err.message}. Aborting...`) + process.nextTick(() => { process.exit(1) }) + }).end() }) return readLocal(coreLocalFile) } @@ -58,7 +61,7 @@ async function getCoreIndex () { return new Promise((resolve) => { const req = request(CORE_RAW_URL, { method: 'HEAD' }, (res) => { if (res.statusCode !== 200) { - console.error('Request to Github failed. Aborting...') + console.error(`Request to Github returned http status ${res.statusCode}. Aborting...`) process.nextTick(() => { process.exit(1) }) } @@ -75,8 +78,8 @@ async function getCoreIndex () { } }) - req.on('error', (e) => { - console.error(`Problem with request: ${e.message}`) + req.on('error', (err) => { + console.error(`Request to Github returned error ${err.message}. Aborting...`) process.nextTick(() => { process.exit(1) }) })