Skip to content
This repository was archived by the owner on Jan 4, 2022. It is now read-only.

Commit d4cf78d

Browse files
committed
connect is now an async function; implemented a 5s retry
1 parent 5f42ada commit d4cf78d

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

common.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,15 @@ function clean() {
7777
exec(`mkdir -p ${localWd}`);
7878
}
7979

80-
function connect() {
80+
async function connect() {
8181
let test = '';
8282
do {
8383
try {
8484
test = exec(`${sdb} -s "${target}" shell echo 1`);
8585
} catch (e) {
8686
console.error(e.message);
87+
console.warn(`Waiting for the device ${target}...`);
88+
await new Promise(cb => setTimeout(cb, 5000));
8789
}
8890
} while (test.trim() != '1');
8991
}
@@ -113,12 +115,12 @@ module.exports = {
113115
generateTag: generateTag,
114116

115117
// Run command as User::Shell
116-
runAsShell: cmd => {
118+
runAsShell: async cmd => {
117119
// Clean localWd folder
118120
clean();
119121

120122
// Connect to the target device
121-
connect();
123+
await connect();
122124

123125
// cmd should be always string
124126
cmd += '';
@@ -172,7 +174,7 @@ module.exports = {
172174
clean();
173175

174176
// Connect to the target device
175-
connect();
177+
await connect();
176178

177179
// cmd should be always string
178180
cmd + '';

0 commit comments

Comments
 (0)