recently ive been writing a program to modify an android device and ran across node-webkit. i have a beautiful GUI now and want to implement adbkit so that the tools will be platform independent.
i have both adbkit and bluebird modules installed to node-modules/ and as far as i can tell everything should work correctly (im very new to the idea of callbacks and promises)
The issue is that even with no device connected im getting a success return 'Done pushing...' instead of 'something went wrong'. Ive tried just testing client.listDevices and get the same issue: positive return regardless of whether device is actually connected.
If anyone has experience with node ADBKIT or JS Promises i would be very grateful for some guidance.
Here is my JS code :
var Promise = require('bluebird')
var adb = require('adbkit')
var client = adb.createClient()
client.listDevices()
.then(function(devices) {
return Promise.map(devices, function(device) {
return client.push(device.id, 'test.txt', '/data/local/tmp/foo.txt')
.then(function(transfer) {
return new Promise(function(resolve, reject) {
transfer.on('progress', function(stats) {
console.log('[%s] Pushed %d bytes so far',
device.id,
stats.bytesTransferred)
})
transfer.on('end', function() {
console.log('[%s] Push complete', device.id)
resolve()
})
transfer.on('error', reject)
})
})
})
})
.then(function() {
alert('Done pushing test.txt to all connected devices')
})
.catch(function(err) {
alert('Something went wrong:', err.stack)
})
To trigger catch
you need to throw
something. So if you want to get error on no devices, you should add if (devices.length <= 0) throw new Error('error description')