mirror of
https://github.com/appium/appium.git
synced 2026-05-02 08:19:52 -05:00
c410201baa
* fix(appium): For extension commands that use prefix "mobile", ensure logEvents() has the name of executed script Related to https://github.com/appium/java-client/issues/2219 * Fix linting * Address comments * Update method name * Address comments * Address comments * Address comments * Add check for accessing method * Addressing comments
28 lines
908 B
TypeScript
28 lines
908 B
TypeScript
import _ from 'lodash';
|
|
import type {Constraints, Driver, DriverClass} from '@appium/types';
|
|
import type {BaseDriver} from '../basedriver/driver';
|
|
|
|
/**
|
|
* Resolves the name of extension method corresponding to an `execute` command string
|
|
* based on the driver's `executeMethodMap`.
|
|
*
|
|
* @param commandName - The command name to resolve.
|
|
* @returns The resolved extension command name if a mapping exists. Otherwise, the original command name.
|
|
*/
|
|
export function resolveExecuteExtensionName<C extends Constraints>(
|
|
this: BaseDriver<C>,
|
|
commandName: string
|
|
): string {
|
|
const Driver = this.constructor as DriverClass<Driver<C>>;
|
|
const methodMap = Driver.executeMethodMap;
|
|
|
|
if (methodMap && _.isPlainObject(methodMap) && commandName in methodMap) {
|
|
const command = methodMap[commandName]?.command;
|
|
if (typeof command === 'string') {
|
|
return command;
|
|
}
|
|
}
|
|
|
|
return commandName;
|
|
}
|