cli: fix typo in download not found code path, close #166

This commit is contained in:
Gleb Bahmutov
2017-06-19 17:37:40 -04:00
parent 70a22ac22a
commit 5767175dae
2 changed files with 20 additions and 7 deletions
+3 -3
View File
@@ -2,7 +2,7 @@ exports['passes --browser option 1'] = [
"--project",
null,
"--cli-version",
"0.19.2",
"0.0.0",
"--browser",
"test browser"
]
@@ -22,7 +22,7 @@ exports['passes --record option 1'] = [
"--record",
"my record id",
"--cli-version",
"0.19.2"
"0.0.0"
]
exports['does not remove --record option when using --browser 1'] = [
@@ -31,7 +31,7 @@ exports['does not remove --record option when using --browser 1'] = [
"--record",
"foo",
"--cli-version",
"0.19.2",
"0.0.0",
"--browser",
"test browser"
]
+17 -4
View File
@@ -49,6 +49,7 @@ const download = (options = {}) => {
// nuke the bar on error
const terminate = (err) => {
debug('problem downloading: %s', err.message)
bar.clear = true
bar.terminate()
reject(err)
@@ -79,9 +80,15 @@ const download = (options = {}) => {
throttle: options.throttle,
})
.on('response', (response) => {
// if our status code doesnt start with 200
// if our status code does not start with 200
if (!(/^2/.test(response.statusCode))) {
terminate(_.pick(response, 'statusCode', 'statusMessage'))
debug('response code %d', response.statusCode)
const err = new Error(stripIndent`
Could not download Cypress binary.
response code: ${response.statusCode}
response message: ${response.statusMessage}
`)
terminate(err)
}
})
.on('error', terminate)
@@ -111,14 +118,20 @@ const download = (options = {}) => {
const statusMessage = (err) =>
err.statusCode ? [err.statusCode, err.statusMessage].join(' - ') : err.toString()
const printAndFail = (text) => {
console.log(text) //eslint-disable-line no-console
process.exit(1)
}
const logErr = (options) => (err) => {
debug('logging download error')
const msg = stripIndent`
URL: ${getUrl(options.version)}
Server response: ${statusMessage(err)}
`
debug(msg)
return formErrorText(errors.failedDownload, new Error(msg))
.then(console.log) //eslint-disable-line no-console
.then(process.exit(1))
.then(printAndFail)
}
const logFinish = (options) => {