Skip to content

Commit 8688718

Browse files
fix bugs
1 parent 419b80b commit 8688718

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

lib/downloader.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,12 @@ exports.get = function (url, options, cb) {
2020
const file = fs.createWriteStream(dest)
2121
response.pipe(file)
2222
file.on('finish', () => {
23-
file.close()
24-
cb(null, dest)
23+
file.close(err => {
24+
if (err) {
25+
return cb(err, null)
26+
}
27+
cb(null, dest)
28+
})
2529
})
2630
file.on('error', err => {
2731
fs.unlink(dest, () => {})

lib/tunnel-launcher.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ function run (options, callback) {
9999
checkJava.on('error', err => {
100100
return callback(new Error(`Java might not be installed, necessary to use testingbot-tunnel ${err.message}`))
101101
})
102+
checkJava.on('spawn', () => {
103+
checkJava.kill()
104+
})
102105

103106
const onReady = function () {
104107
started = true
@@ -176,13 +179,9 @@ function run (options, callback) {
176179

177180
activeTunnel.close = closeCallback => {
178181
if (closeCallback) {
179-
if (!activeTunnel) {
182+
activeTunnel.on('close', () => {
180183
closeCallback()
181-
} else {
182-
activeTunnel.on('close', () => {
183-
closeCallback()
184-
})
185-
}
184+
})
186185
}
187186
activeTunnel.kill('SIGINT')
188187
}

0 commit comments

Comments
 (0)