mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-18 08:13:31 +02:00
Move more work to devutil.
This commit is contained in:
@@ -90,33 +90,23 @@ module.exports = function(options) {
|
||||
])
|
||||
})
|
||||
.then(function() {
|
||||
var port = 2870
|
||||
return adb.openTcpAsync(options.serial, port)
|
||||
.then(function(conn) {
|
||||
conn.end()
|
||||
throw new Error(util.format('Old connection still lives on port %d', port))
|
||||
})
|
||||
.catch(function(err) {
|
||||
if (err.message === 'closed') {
|
||||
return adb.shellAsync(options.serial, [
|
||||
vendor.bin.dest
|
||||
, '--lib', vendor.lib.dest
|
||||
, '--listen-http', port
|
||||
])
|
||||
.then(function(out) {
|
||||
out.pipe(require('split')())
|
||||
.on('data', function(chunk) {
|
||||
log.info('remote: "%s"', chunk)
|
||||
})
|
||||
.on('end', function() {
|
||||
log.fatal('remote: Connection closed')
|
||||
selfDestruct()
|
||||
})
|
||||
})
|
||||
}
|
||||
else {
|
||||
throw err
|
||||
}
|
||||
return devutil.ensureUnusedPort(adb, options.serial, 2870)
|
||||
.then(function(port) {
|
||||
return adb.shellAsync(options.serial, [
|
||||
vendor.bin.dest
|
||||
, '--lib', vendor.lib.dest
|
||||
, '--listen-http', port
|
||||
])
|
||||
.then(function(out) {
|
||||
out.pipe(require('split')())
|
||||
.on('data', function(chunk) {
|
||||
log.info('remote: "%s"', chunk)
|
||||
})
|
||||
.on('end', function() {
|
||||
log.fatal('remote: Connection closed')
|
||||
selfDestruct()
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
.done(function() {
|
||||
|
||||
Reference in New Issue
Block a user