-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.js
38 lines (31 loc) · 853 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
module.exports = function (options, next) {
var exec = require('child_process').spawn;
var a = 'adb';
var cmd = [];
if (typeof options.deviceID === 'string') {
cmd.push('-s');
cmd.push(options.deviceID);
}
if (typeof options.shell === 'object') {
cmd = cmd.concat(options.shell);
}
var ls = exec(a, cmd);
var useNext = false;
ls.stdout.on('data', function (data) {
useNext = true;
next && next(data.toString());
});
ls.stderr.on('data', function (data) {
//console.log(data.toString());
});
ls.on('exit', function () {
if (typeof next === 'function') {
if (useNext === false) {
setTimeout(function () {
next();
}, 200);
}
}
});
return ls;
};