Skip to content

Commit

Permalink
chore: fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
imurchie committed Jan 7, 2019
1 parent 52de680 commit 93c60f9
Show file tree
Hide file tree
Showing 31 changed files with 268 additions and 268 deletions.
2 changes: 1 addition & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"use strict";
'use strict';

const { exec } = require('teen_process');
const system = require('appium-support').system;
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import * as server from './lib/server';

const { startServer } = server;

const DEFAULT_HOST = "localhost";
const DEFAULT_HOST = 'localhost';
const DEFAULT_PORT = 4723;

async function main () {
Expand Down
42 changes: 21 additions & 21 deletions lib/android-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ helpers.createBaseADB = async function (opts = {}) {
};

helpers.parseJavaVersion = function (stderr) {
let lines = stderr.split("\n");
let lines = stderr.split('\n');
for (let line of lines) {
if (new RegExp(/(java|openjdk) version/).test(line)) {
return line.split(" ")[2].replace(/"/g, '');
return line.split(' ')[2].replace(/"/g, '');
}
}
return null;
Expand All @@ -94,7 +94,7 @@ helpers.getJavaVersion = async function (logVersion = true) {
let {stderr} = await exec('java', ['-version']);
let javaVer = helpers.parseJavaVersion(stderr);
if (javaVer === null) {
throw new Error("Could not get the Java version. Is Java installed?");
throw new Error('Could not get the Java version. Is Java installed?');
}
if (logVersion) {
logger.info(`Java version is: ${javaVer}`);
Expand All @@ -112,16 +112,16 @@ helpers.prepareEmulator = async function (adb, opts) {
avdReadyTimeout,
} = opts;
if (!avd) {
throw new Error("Cannot launch AVD without AVD name");
throw new Error('Cannot launch AVD without AVD name');
}
let avdName = avd.replace('@', '');
let runningAVD = await adb.getRunningAVD(avdName);
if (runningAVD !== null) {
if (avdArgs && avdArgs.toLowerCase().indexOf("-wipe-data") > -1) {
if (avdArgs && avdArgs.toLowerCase().indexOf('-wipe-data') > -1) {
logger.debug(`Killing '${avdName}' because it needs to be wiped at start.`);
await adb.killEmulator(avdName);
} else {
logger.debug("Not launching AVD because it is already running.");
logger.debug('Not launching AVD because it is already running.');
return;
}
}
Expand Down Expand Up @@ -193,7 +193,7 @@ helpers.getDeviceInfoFromCaps = async function (opts = {}) {
emPort = adb.emulatorPort;
} else {
// no avd given. lets try whatever's plugged in devices/emulators
logger.info("Retrieving device list");
logger.info('Retrieving device list');
let devices = await adb.getDevicesWithRetry();

// udid was given, lets try to init with that device
Expand Down Expand Up @@ -279,7 +279,7 @@ helpers.validatePackageActivityNames = function (opts) {
helpers.getLaunchInfo = async function (adb, opts) {
let {app, appPackage, appActivity, appWaitPackage, appWaitActivity} = opts;
if (!app) {
logger.warn("No app sent in, not parsing package/activity");
logger.warn('No app sent in, not parsing package/activity');
return;
}

Expand All @@ -289,7 +289,7 @@ helpers.getLaunchInfo = async function (adb, opts) {
return;
}

logger.debug("Parsing package and activity from app manifest");
logger.debug('Parsing package and activity from app manifest');
let {apkPackage, apkActivity} =
await adb.packageAndLaunchActivityFromManifest(app);
if (apkPackage && !appPackage) {
Expand Down Expand Up @@ -460,7 +460,7 @@ helpers.installHelperApp = async function (adb, apkPath, packageId, appName) {
};

helpers.pushSettingsApp = async function (adb, throwError = false) {
logger.debug("Pushing settings apk to device...");
logger.debug('Pushing settings apk to device...');

await helpers.installHelperApp(adb, settingsApkPath, SETTINGS_HELPER_PKG_ID, 'Settings');

Expand Down Expand Up @@ -489,9 +489,9 @@ helpers.pushSettingsApp = async function (adb, throwError = false) {
await adb.startApp({
pkg: SETTINGS_HELPER_PKG_ID,
activity: SETTINGS_HELPER_MAIN_ACTIVITY,
action: "android.intent.action.MAIN",
category: "android.intent.category.LAUNCHER",
flags: "0x10200000",
action: 'android.intent.action.MAIN',
category: 'android.intent.category.LAUNCHER',
flags: '0x10200000',
stopApp: false,
});
} catch (err) {
Expand Down Expand Up @@ -570,7 +570,7 @@ helpers.unlockWithUIAutomation = async function (driver, adb, unlockCapabilities
};

helpers.unlockWithHelperApp = async function (adb) {
logger.info("Unlocking screen");
logger.info('Unlocking screen');

// Unlock succeed with a couple of retries.
let firstRun = true;
Expand All @@ -585,8 +585,8 @@ helpers.unlockWithHelperApp = async function (adb) {
}
} catch (e) {
logger.warn(`Error in isScreenLocked: ${e.message}`);
logger.warn("\"adb shell dumpsys window\" command has timed out.");
logger.warn("The reason of this timeout is the delayed adb response. Resetting adb server can improve it.");
logger.warn('"adb shell dumpsys window" command has timed out.');
logger.warn('The reason of this timeout is the delayed adb response. Resetting adb server can improve it.');
}
}

Expand All @@ -604,13 +604,13 @@ helpers.unlockWithHelperApp = async function (adb) {

helpers.unlock = async function (driver, adb, capabilities) {
if (!(await adb.isScreenLocked())) {
logger.info("Screen already unlocked, doing nothing");
logger.info('Screen already unlocked, doing nothing');
return;
}

logger.debug("Screen is locked, trying to unlock");
logger.debug('Screen is locked, trying to unlock');
if (_.isUndefined(capabilities.unlockType)) {
logger.warn("Using app unlock, this is going to be deprecated!");
logger.warn('Using app unlock, this is going to be deprecated!');
await helpers.unlockWithHelperApp(adb);
} else {
await helpers.unlockWithUIAutomation(driver, adb, {unlockType: capabilities.unlockType, unlockKey: capabilities.unlockKey});
Expand All @@ -621,9 +621,9 @@ helpers.unlock = async function (driver, adb, capabilities) {
helpers.verifyUnlock = async function (adb) {
await retryInterval(2, 1000, async () => {
if (await adb.isScreenLocked()) {
throw new Error("Screen did not unlock successfully, retrying");
throw new Error('Screen did not unlock successfully, retrying');
}
logger.debug("Screen unlocked successfully");
logger.debug('Screen unlocked successfully');
});
};

Expand Down
2 changes: 1 addition & 1 deletion lib/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class AndroidBootstrap {
}
});
this.socketClient.once('connect', () => {
log.info("Android bootstrap socket is now connected");
log.info('Android bootstrap socket is now connected');
resolve();
});
} catch (err) {
Expand Down
42 changes: 21 additions & 21 deletions lib/commands/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,23 @@ let commands = {}, helpers = {}, extensions = {};

commands.keyevent = async function (keycode, metastate = null) {
// TODO deprecate keyevent; currently wd only implements keyevent
log.warn("keyevent will be deprecated use pressKeyCode");
log.warn('keyevent will be deprecated use pressKeyCode');
return await this.pressKeyCode(keycode, metastate);
};

commands.pressKeyCode = async function (keycode, metastate = null) {
return await this.bootstrap.sendAction("pressKeyCode", {keycode, metastate});
return await this.bootstrap.sendAction('pressKeyCode', {keycode, metastate});
};

commands.longPressKeyCode = async function (keycode, metastate = null) {
return await this.bootstrap.sendAction("longPressKeyCode", {keycode, metastate});
return await this.bootstrap.sendAction('longPressKeyCode', {keycode, metastate});
};

commands.getOrientation = async function () {
let params = {
naturalOrientation: !!this.opts.androidNaturalOrientation,
};
let orientation = await this.bootstrap.sendAction("orientation", params);
let orientation = await this.bootstrap.sendAction('orientation', params);
return orientation.toUpperCase();
};

Expand All @@ -45,7 +45,7 @@ commands.setOrientation = async function (orientation) {
orientation,
naturalOrientation: !!this.opts.androidNaturalOrientation,
};
return await this.bootstrap.sendAction("orientation", params);
return await this.bootstrap.sendAction('orientation', params);
};

commands.fakeFlick = async function (xSpeed, ySpeed) {
Expand Down Expand Up @@ -76,9 +76,9 @@ commands.swipe = async function (startX, startY, endX, endY, duration, touchCoun

commands.doSwipe = async function (swipeOpts) {
if (util.hasValue(swipeOpts.elementId)) {
return await this.bootstrap.sendAction("element:swipe", swipeOpts);
return await this.bootstrap.sendAction('element:swipe', swipeOpts);
} else {
return await this.bootstrap.sendAction("swipe", swipeOpts);
return await this.bootstrap.sendAction('swipe', swipeOpts);
}
};

Expand All @@ -89,12 +89,12 @@ commands.pinchClose = async function (startX, startY, endX, endY, duration, perc
percent,
steps
};
return await this.bootstrap.sendAction("element:pinch", pinchOpts);
return await this.bootstrap.sendAction('element:pinch', pinchOpts);
};

commands.pinchOpen = async function (startX, startY, endX, endY, duration, percent, steps, elId) {
let pinchOpts = {direction: 'out', elementId: elId, percent, steps};
return await this.bootstrap.sendAction("element:pinch", pinchOpts);
return await this.bootstrap.sendAction('element:pinch', pinchOpts);
};

commands.flick = async function (element, xSpeed, ySpeed, xOffset, yOffset, speed) {
Expand All @@ -116,9 +116,9 @@ commands.drag = async function (startX, startY, endX, endY, duration, touchCount

commands.doDrag = async function (dragOpts) {
if (util.hasValue(dragOpts.elementId)) {
return await this.bootstrap.sendAction("element:drag", dragOpts);
return await this.bootstrap.sendAction('element:drag', dragOpts);
} else {
return await this.bootstrap.sendAction("drag", dragOpts);
return await this.bootstrap.sendAction('drag', dragOpts);
}
};

Expand All @@ -145,7 +145,7 @@ commands.unlock = async function () {
};

commands.openNotifications = async function () {
return await this.bootstrap.sendAction("openNotification");
return await this.bootstrap.sendAction('openNotification');
};

commands.setLocation = async function (latitude, longitude) {
Expand Down Expand Up @@ -233,7 +233,7 @@ commands.pushFile = async function (remotePath, base64Data) {

// if we have pushed a file, it might be a media file, so ensure that
// apps know about it
log.info("After pushing media file, broadcasting media scan intent");
log.info('After pushing media file, broadcasting media scan intent');
try {
await this.adb.shell(['am', 'broadcast', '-a',
ANDROID_MEDIA_RESCAN_INTENT, '-d', `file://${remotePath}`]);
Expand All @@ -259,56 +259,56 @@ commands.pullFolder = async function (remotePath) {

commands.fingerprint = async function (fingerprintId) {
if (!this.isEmulator()) {
log.errorAndThrow("fingerprint method is only available for emulators");
log.errorAndThrow('fingerprint method is only available for emulators');
}
await this.adb.fingerprint(fingerprintId);
};

commands.sendSMS = async function (phoneNumber, message) {
if (!this.isEmulator()) {
log.errorAndThrow("sendSMS method is only available for emulators");
log.errorAndThrow('sendSMS method is only available for emulators');
}
await this.adb.sendSMS(phoneNumber, message);
};

commands.gsmCall = async function (phoneNumber, action) {
if (!this.isEmulator()) {
log.errorAndThrow("gsmCall method is only available for emulators");
log.errorAndThrow('gsmCall method is only available for emulators');
}
await this.adb.gsmCall(phoneNumber, action);
};

commands.gsmSignal = async function (signalStrengh) {
if (!this.isEmulator()) {
log.errorAndThrow("gsmSignal method is only available for emulators");
log.errorAndThrow('gsmSignal method is only available for emulators');
}
await this.adb.gsmSignal(signalStrengh);
};

commands.gsmVoice = async function (state) {
if (!this.isEmulator()) {
log.errorAndThrow("gsmVoice method is only available for emulators");
log.errorAndThrow('gsmVoice method is only available for emulators');
}
await this.adb.gsmVoice(state);
};

commands.powerAC = async function (state) {
if (!this.isEmulator()) {
log.errorAndThrow("powerAC method is only available for emulators");
log.errorAndThrow('powerAC method is only available for emulators');
}
await this.adb.powerAC(state);
};

commands.powerCapacity = async function (batteryPercent) {
if (!this.isEmulator()) {
log.errorAndThrow("powerCapacity method is only available for emulators");
log.errorAndThrow('powerCapacity method is only available for emulators');
}
await this.adb.powerCapacity(batteryPercent);
};

commands.networkSpeed = async function (networkSpeed) {
if (!this.isEmulator()) {
log.errorAndThrow("networkSpeed method is only available for emulators");
log.errorAndThrow('networkSpeed method is only available for emulators');
}
await this.adb.networkSpeed(networkSpeed);
};
Expand Down
18 changes: 9 additions & 9 deletions lib/commands/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ helpers.switchContext = async function (name) {
// to true then kill chromedriver session using stopChromedriverProxies or
// else simply suspend proxying to the latter
if (this.opts.recreateChromeDriverSessions) {
log.debug("recreateChromeDriverSessions set to true; killing existing chromedrivers");
log.debug('recreateChromeDriverSessions set to true; killing existing chromedrivers');
await this.stopChromedriverProxies();
} else {
await this.suspendChromedriverProxy();
Expand Down Expand Up @@ -150,13 +150,13 @@ helpers.onChromedriverStop = async function (context) {
if (context === this.curContext) {
// we exited unexpectedly while automating the current context and so want
// to shut down the session and respond with an error
let err = new Error("Chromedriver quit unexpectedly during session");
let err = new Error('Chromedriver quit unexpectedly during session');
await this.startUnexpectedShutdown(err);
} else {
// if a Chromedriver in the non-active context barfs, we don't really
// care, we'll just make a new one next time we need the context.
log.warn("Chromedriver quit unexpectedly, but it wasn't the active " +
"context, ignoring");
'context, ignoring');
delete this.sessionChromedrivers[context];
}
};
Expand Down Expand Up @@ -190,10 +190,10 @@ helpers.shouldDismissChromeWelcome = function shouldDismissChromeWelcome () {
};

helpers.dismissChromeWelcome = async function dismissChromeWelcome () {
log.info("Trying to dismiss Chrome welcome");
log.info('Trying to dismiss Chrome welcome');
let activity = await this.getCurrentActivity();
if (activity !== "org.chromium.chrome.browser.firstrun.FirstRunActivity") {
log.info("Chrome welcome dialog never showed up! Continuing");
if (activity !== 'org.chromium.chrome.browser.firstrun.FirstRunActivity') {
log.info('Chrome welcome dialog never showed up! Continuing');
return;
}
let el = await this.findElOrEls('id', 'com.android.chrome:id/terms_accept', false);
Expand All @@ -209,7 +209,7 @@ helpers.dismissChromeWelcome = async function dismissChromeWelcome () {
};

helpers.startChromeSession = async function startChromeSession () {
log.info("Starting a chrome-based browser session");
log.info('Starting a chrome-based browser session');
let opts = _.cloneDeep(this.opts);
opts.chromeUseRunningApp = false;

Expand Down Expand Up @@ -256,8 +256,8 @@ async function setupExistingChromedriver (chromedriver) {
// check the status by sending a simple window-based command to ChromeDriver
// if there is an error, we want to recreate the ChromeDriver session
if (!await chromedriver.hasWorkingWebview()) {
log.debug("ChromeDriver is not associated with a window. " +
"Re-initializing the session.");
log.debug('ChromeDriver is not associated with a window. ' +
'Re-initializing the session.');
await chromedriver.restart();
}
return chromedriver;
Expand Down
Loading

0 comments on commit 93c60f9

Please sign in to comment.