I am using shellJs with node webkit to work on an android tablet. what i want to do is use shelljs to Fastboot read a bootloader variable (product). But in Fastboot if no device is connected the return is "waiting-for-device" and the connection is left open. What i'd like to do is let this command run for up to 5 seconds, then if the output != 'Soho' throw an error and cancel function.
This is my current code
$('#fbbtn').click(function(){
var getVar = terminal.exec('fastboot -i 0x1949 getvar product');
var getSerial = terminal.exec('fastboot -i 0x1949 devices');
var test getVar.output.match(/Soho/g);
if(test=='Soho'){
fbSerial=getSerial.output.substr(0,16);
}
else alert('ERROR');
});
I know that exec from shelljs offers {async:true} but dont understand promises well, and cant find very good documentation about them. Hopefully someone can educate me a bit here