Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
helpers.parseTouch = async function parseTouch (gestures, multi) {
// because multi-touch releases at the end by default
if (multi && _.last(gestures).action === 'release') {
gestures.pop();
}
let touchStateObjects = await asyncmap(gestures, async (gesture) => {
let options = gesture.options || {};
if (_.includes(['press', 'moveTo', 'tap', 'longPress'], gesture.action)) {
options.offset = false;
let elementId = gesture.options.element;
if (elementId) {
let pos = await this.getLocationInView(elementId);
if (gesture.options.x || gesture.options.y) {
options.x = pos.x + (gesture.options.x || 0);
options.y = pos.y + (gesture.options.y || 0);
} else {
const {width, height} = await this.getSize(elementId);
options.x = pos.x + (width / 2);
options.y = pos.y + (height / 2);
}
let touchStateObject = {
action: gesture.action,
async getChromedrivers (mapping) {
// go through the versions available
const executables = await fs.glob(`${this.executableDir}/*`);
log.debug(`Found ${executables.length} executable${executables.length === 1 ? '' : 's'} ` +
`in '${this.executableDir}'`);
const cds = (await asyncmap(executables, async function mapChromedriver (executable) {
const logError = ({message, stdout = null, stderr = null}) => {
let errMsg = `Cannot retrieve version number from '${path.basename(executable)}' Chromedriver binary. ` +
`Make sure it returns a valid version string in response to '--version' command line argument. ${message}`;
if (stdout) {
errMsg += `\nStdout: ${stdout}`;
}
if (stderr) {
errMsg += `\nStderr: ${stderr}`;
}
log.warn(errMsg);
return null;
};
let stdout;
let stderr;
try {
async isFresh () {
// if the following files don't exist, it hasn't been booted.
// THIS IS NOT AN EXHAUSTIVE LIST
let files = this.isFreshFiles;
let pv = await this.getPlatformVersion();
if (pv !== '7.1') {
files.push('Library/Preferences/com.apple.Preferences.plist');
} else {
files.push('Applications');
}
const dir = this.getDir();
files = files.map((s) => path.resolve(dir, s));
const existences = await asyncmap(files, async (f) => await fs.hasAccess(f));
const fresh = _.compact(existences).length !== files.length;
log.debug(`Checking whether simulator has been run before: ${fresh ? 'no' : 'yes'}`);
return fresh;
}
};
// given a directory, return the path and bundle id associated with it
pathBundlePair = async (dir) => {
dir = path.resolve(applicationList, dir);
let bundleId = await readBundleId(dir);
return {path: dir, bundleId};
};
}
if (!await fs.exists(applicationList)) {
log.warn(`No directory path '${applicationList}'`);
return {};
}
let bundlePathDirs = await fs.readdir(applicationList);
let bundlePathPairs = await asyncmap(bundlePathDirs, async (dir) => {
return await pathBundlePair(dir);
}, false);
// reduce the list of path-bundle pairs to an object where bundleIds are mapped to paths
return bundlePathPairs.reduce((bundleMap, bundlePath) => {
bundleMap[bundlePath.bundleId] = bundlePath.path;
return bundleMap;
}, {});
}
false /*ensure serial operation*/);
} else {
logger.info('Not checking whether webviews have active pages; use the ' +
"'ensureWebviewsHavePages' cap to turn this check on");
}
// webviewProcs contains procs, which we only care about for ensuring
// presence of pages above, so we can now discard them and rely on just the
// webview names
let webviews = webviewProcs.map((wp) => wp.webview);
if (androidDeviceSocket) {
return webviews;
}
webviews = await asyncmap(webviews, async (webviewName) => {
let pkg = await helpers.procFromWebview(adb, webviewName);
return WEBVIEW_BASE + pkg;
});
logger.debug(`Found webviews: ${JSON.stringify(webviews)}`);
return webviews;
};
async function getData () {
return await asyncmap(realFiles, (file) => {
return settings.read(file);
}, true);
}