Created
January 2, 2018 21:28
-
-
Save Jorger/49a7097048b4c26f11ca1e5d89bf2433 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const sockets = require('./sockets'); | |
const exec = require('child-process-promise').exec; | |
const { | |
ADB_DIRECTORY, | |
AAPT_DIRECTORY, | |
} = require('../config').adb; | |
//Ejecuta acciones ADB shell.. | |
exports.processADB = (command, typeAction = ADB_DIRECTORY, props = {}) => { | |
return new Promise(async (resolve, reject) => { | |
//Valores opcionales que pueden o no llegar... | |
props.viewTerminal = props.viewTerminal || false; | |
props.room = props.room || ""; | |
props.contCommad = props.contCommad || {enabled : false}; | |
props.finish = props.finish || false; | |
props.iddevice = props.iddevice || 0; | |
props.idapk = props.idapk || 0; | |
try { | |
const txtComand = ( | |
props.contCommad.enabled ? `Evento ${props.contCommad.num} de ${props.contCommad.total}: ` : "" | |
) + `${typeAction} ${command}`; | |
if(props.viewTerminal) { | |
sockets.comandsTerminal( | |
props.room, | |
txtComand, | |
props.finish, | |
props.iddevice, | |
props.idapk | |
); | |
} | |
const ADB = await exec( | |
`${typeAction} ${command}` | |
); | |
resolve( | |
ADB.stdout | |
); | |
} catch (e) { | |
reject( | |
e | |
); | |
} | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment