Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function doInstall () {
// UiAutomator2 needs Java. Fail early if it doesn't exist
let androidHelpers = require('appium-android-driver').androidHelpers;
androidHelpers.getJavaVersion().then(function () {
let tries = 0;
function onErr (err) {
console.log(err.message);
let codeNotBuilt = err.message.indexOf('Cannot find module') !== -1;
if (tries >= MAX_ATTEMPTS) {
console.log("Tried too many times to install UiAutomator2, failing");
console.log("Original error: " + err.message);
throw new Error("Unable to import and run the installer. " +
"If you're running from source, run `gulp transpile` " +
"and then re-run `npm install`");
}
tries++;
if (codeNotBuilt && !attemptedToBuild) {
attemptedToBuild = true;
console.log("Attempting to transpile setup code...");
exec("npm run transpile", {cwd: path.resolve(__dirname, "..")}, function (err) {