Skip to content

Commit 68a290e

Browse files
feat: Ditch bluebird (#996)
1 parent 40c0fd7 commit 68a290e

16 files changed

Lines changed: 254 additions & 236 deletions

lib/commands/app-management.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import _ from 'lodash';
2-
import B from 'bluebird';
32
import {errors} from 'appium/driver';
43
import {APK_EXTENSION} from '../extensions';
54
import type {AndroidUiautomator2Driver} from '../driver';
@@ -19,7 +18,7 @@ export async function mobileInstallMultipleApks(
1918
if (!_.isArray(apks) || _.isEmpty(apks)) {
2019
throw new errors.InvalidArgumentError('No apks are given to install');
2120
}
22-
const configuredApks = await B.all(
21+
const configuredApks = await Promise.all(
2322
apks.map((app) => this.helpers.configureApp(app, [APK_EXTENSION])),
2423
);
2524
await this.adb.installMultipleApks(configuredApks, options);

lib/commands/element.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import {PROTOCOLS} from 'appium/driver';
2-
import B from 'bluebird';
32
import _ from 'lodash';
43
import type {DoSetElementValueOpts} from 'appium-android-driver';
54
import type {Element as AppiumElement, Position, Rect, Size} from '@appium/types';
@@ -190,7 +189,7 @@ export async function getElementRect(
190189

191190
const chromedriver = this.chromedriver as Chromedriver;
192191
if (chromedriver.jwproxy.downstreamProtocol === PROTOCOLS.MJSONWP) {
193-
const [{x, y}, {width, height}] = (await B.all([
192+
const [{x, y}, {width, height}] = (await Promise.all([
194193
chromedriver.jwproxy.command(`/element/${elementId}/location`, 'GET'),
195194
chromedriver.jwproxy.command(`/element/${elementId}/size`, 'GET'),
196195
])) as [Position, Size];

lib/commands/screenshot.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import _ from 'lodash';
2-
import B from 'bluebird';
32
import {imageUtil} from 'appium/support';
43
import type {AndroidUiautomator2Driver} from '../driver';
54
import type {Screenshot} from './types';
@@ -125,7 +124,7 @@ export async function mobileScreenshots(
125124
const allInfos = _.values(infos).filter(
126125
(info): info is Partial<Screenshot> & {id: string} => !!info?.id,
127126
);
128-
const screenshots = await B.all(allInfos.map((info) => toB64Screenshot(info.id)));
127+
const screenshots = await Promise.all(allInfos.map((info) => toB64Screenshot(info.id)));
129128
for (const [info, payload] of _.zip(allInfos, screenshots) as Array<
130129
[Partial<Screenshot>, string]
131130
>) {

lib/css-converter.ts

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -67,50 +67,6 @@ const isAstClassName = (item: {type?: string}): item is AstClassName => item.typ
6767
const isAstTagName = (item: {type?: string}): item is AstTagName => item.type === 'TagName';
6868
const isAstId = (item: {type?: string}): item is AstId => item.type === 'Id';
6969

70-
function toSnakeCase(str?: string | null): string {
71-
if (!str) {
72-
return '';
73-
}
74-
const tokens = str
75-
.split('-')
76-
.map((token) => token.charAt(0).toUpperCase() + token.slice(1).toLowerCase());
77-
const out = tokens.join('');
78-
return out.charAt(0).toLowerCase() + out.slice(1);
79-
}
80-
81-
function requireBoolean(css: AstAttribute | AstPseudoClass): 'true' | 'false' {
82-
const rawValue = (css as any).value?.value ?? (css as any).argument?.value;
83-
const value = _.toLower(rawValue ?? 'true');
84-
if (value === 'true') {
85-
return 'true';
86-
}
87-
if (value === 'false') {
88-
return 'false';
89-
}
90-
throw new Error(`'${css.name}' must be true, false or empty. Found '${(css as any).value}'`);
91-
}
92-
93-
function requireEntityName(cssEntity: AstAttribute | AstPseudoClass): string {
94-
const attrName = cssEntity.name.toLowerCase();
95-
96-
if (ALL_ATTRS.includes(attrName)) {
97-
return attrName;
98-
}
99-
100-
for (const [officialAttr, aliasAttrs] of ATTRIBUTE_ALIASES) {
101-
if (aliasAttrs.includes(attrName)) {
102-
return officialAttr;
103-
}
104-
}
105-
throw new Error(
106-
`'${attrName}' is not a valid attribute. Supported attributes are '${ALL_ATTRS.join(', ')}'`,
107-
);
108-
}
109-
110-
function getWordMatcherRegex(word: string): string {
111-
return `\\b(\\w*${_.escapeRegExp(word)}\\w*)\\b`;
112-
}
113-
11470
export class CssConverter {
11571
constructor(
11672
private readonly selector: string,
@@ -277,3 +233,47 @@ export class CssConverter {
277233
throw new Error('No rules could be parsed out of the current selector');
278234
}
279235
}
236+
237+
function toSnakeCase(str?: string | null): string {
238+
if (!str) {
239+
return '';
240+
}
241+
const tokens = str
242+
.split('-')
243+
.map((token) => token.charAt(0).toUpperCase() + token.slice(1).toLowerCase());
244+
const out = tokens.join('');
245+
return out.charAt(0).toLowerCase() + out.slice(1);
246+
}
247+
248+
function requireBoolean(css: AstAttribute | AstPseudoClass): 'true' | 'false' {
249+
const rawValue = (css as any).value?.value ?? (css as any).argument?.value;
250+
const value = _.toLower(rawValue ?? 'true');
251+
if (value === 'true') {
252+
return 'true';
253+
}
254+
if (value === 'false') {
255+
return 'false';
256+
}
257+
throw new Error(`'${css.name}' must be true, false or empty. Found '${(css as any).value}'`);
258+
}
259+
260+
function requireEntityName(cssEntity: AstAttribute | AstPseudoClass): string {
261+
const attrName = cssEntity.name.toLowerCase();
262+
263+
if (ALL_ATTRS.includes(attrName)) {
264+
return attrName;
265+
}
266+
267+
for (const [officialAttr, aliasAttrs] of ATTRIBUTE_ALIASES) {
268+
if (aliasAttrs.includes(attrName)) {
269+
return officialAttr;
270+
}
271+
}
272+
throw new Error(
273+
`'${attrName}' is not a valid attribute. Supported attributes are '${ALL_ATTRS.join(', ')}'`,
274+
);
275+
}
276+
277+
function getWordMatcherRegex(word: string): string {
278+
return `\\b(\\w*${_.escapeRegExp(word)}\\w*)\\b`;
279+
}

0 commit comments

Comments
 (0)