Skip to content

Commit 34efb7d

Browse files
ditch bluebird
1 parent 9c3e69e commit 34efb7d

5 files changed

Lines changed: 22 additions & 25 deletions

File tree

Scripts/fetch-prebuilt-wda.mjs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { readFileSync } from 'node:fs';
44
import axios from 'axios';
55
import { logger, fs, mkdirp, net } from '@appium/support';
66
import _ from 'lodash';
7-
import B from 'bluebird';
87

98
const __filename = fileURLToPath(import.meta.url);
109
const __dirname = path.dirname(__filename);
@@ -60,7 +59,7 @@ async function fetchPrebuiltWebDriverAgentAssets () {
6059
}
6160

6261
// Wait for them all to finish
63-
return await B.all(agentsDownloading);
62+
return await Promise.all(agentsDownloading);
6463
}
6564

6665
if (isMainModule) {

lib/utils.ts

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {fileURLToPath} from 'node:url';
55
import {log} from './logger';
66
import _ from 'lodash';
77
import {PLATFORM_NAME_TVOS} from './constants';
8-
import B from 'bluebird';
98
import _fs from 'node:fs';
109
import {waitForCondition} from 'asyncbox';
1110
import {arch} from 'node:os';
@@ -90,7 +89,7 @@ export async function killAppUsingPattern(pgrepPattern: string): Promise<void> {
9089
return true;
9190
}
9291
});
93-
return (await B.all(pidCheckPromises)).every((x) => x === true);
92+
return (await Promise.all(pidCheckPromises)).every((x) => x === true);
9493
},
9594
{
9695
waitMs: 1000,
@@ -305,7 +304,7 @@ export async function resetTestProcesses(udid: string, isSimulator: boolean): Pr
305304
processPatterns.push(`xctest.*${udid}`);
306305
}
307306
log.debug(`Killing running processes '${processPatterns.join(', ')}' for the device ${udid}...`);
308-
await B.all(processPatterns.map(killAppUsingPattern));
307+
await Promise.all(processPatterns.map(killAppUsingPattern));
309308
}
310309

311310
/**
@@ -341,19 +340,22 @@ export async function getPIDsListeningOnPort(
341340
if (!_.isFunction(filteringFunc)) {
342341
return result;
343342
}
344-
return await B.filter(result, async (pid) => {
345-
let stdout: string;
346-
try {
347-
({stdout} = await exec('ps', ['-p', pid, '-o', 'command']));
348-
} catch (e: any) {
349-
if (e.code === 1) {
350-
// The process does not exist anymore, there's nothing to filter
351-
return false;
343+
const filtered = await Promise.all(
344+
result.map(async (pid) => {
345+
let stdout: string;
346+
try {
347+
({stdout} = await exec('ps', ['-p', pid, '-o', 'command']));
348+
} catch (e: any) {
349+
if (e.code === 1) {
350+
// The process does not exist anymore, there's nothing to filter
351+
return null;
352+
}
353+
throw e;
352354
}
353-
throw e;
354-
}
355-
return await filteringFunc(stdout);
356-
});
355+
return (await filteringFunc(stdout)) ? pid : null;
356+
}),
357+
);
358+
return filtered.filter((pid): pid is string => Boolean(pid));
357359
}
358360

359361
// Private functions

lib/webdriveragent.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import {waitForCondition} from 'asyncbox';
22
import _ from 'lodash';
33
import path from 'node:path';
4-
import B from 'bluebird';
54
import {JWProxy} from '@appium/base-driver';
65
import {fs, util, plist} from '@appium/support';
76
import type {AppiumLogger, StringRecord} from '@appium/types';
@@ -358,7 +357,7 @@ export class WebDriverAgent {
358357
const existsPromises = ['Resources', `Resources${path.sep}WebDriverAgent.bundle`].map(
359358
(subPath) => fs.exists(path.resolve(this.bootstrapPath, subPath)),
360359
);
361-
return (await B.all(existsPromises)).some((v) => v === false);
360+
return (await Promise.all(existsPromises)).some((v) => v === false);
362361
}
363362

364363
/**

lib/xcodebuild.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import {SubProcess, exec} from 'teen_process';
33
import {logger, timing} from '@appium/support';
44
import type {AppiumLogger, StringRecord} from '@appium/types';
55
import {log as defaultLogger} from './logger';
6-
import B from 'bluebird';
76
import {
87
setRealDeviceSecurity,
98
setXctestrunFile,
@@ -207,7 +206,7 @@ export class XcodeBuild {
207206

208207
if (this.prebuildDelay > 0) {
209208
// pause a moment
210-
await B.delay(this.prebuildDelay);
209+
await new Promise((resolve) => setTimeout(resolve, this.prebuildDelay));
211210
}
212211
}
213212

@@ -242,7 +241,7 @@ export class XcodeBuild {
242241
throw new Error('xcodebuild subprocess was not created');
243242
}
244243
const xcodebuild = this.xcodebuild;
245-
return await new B((resolve, reject) => {
244+
return await new Promise<StringRecord | void>((resolve, reject) => {
246245
xcodebuild.once('exit', (code, signal) => {
247246
xcodeLog.error(`xcodebuild exited with code '${code}' and signal '${signal}'`);
248247
xcodebuild.removeAllListeners();

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,15 @@
5454
"@appium/types": "^1.0.0-rc.1",
5555
"@semantic-release/changelog": "^6.0.1",
5656
"@semantic-release/git": "^10.0.1",
57-
"@types/bluebird": "^3.5.38",
5857
"@types/lodash": "^4.14.196",
5958
"@types/mocha": "^10.0.1",
6059
"@types/node": "^25.0.0",
6160
"appium-xcode": "^6.0.0",
6261
"chai": "^6.0.0",
6362
"chai-as-promised": "^8.0.0",
6463
"conventional-changelog-conventionalcommits": "^9.0.0",
65-
"node-simctl": "^8.0.0",
6664
"mocha": "^11.0.1",
65+
"node-simctl": "^8.0.0",
6766
"prettier": "^3.0.0",
6867
"semantic-release": "^25.0.2",
6968
"semver": "^7.3.7",
@@ -80,7 +79,6 @@
8079
"async-lock": "^1.0.0",
8180
"asyncbox": "^6.1.0",
8281
"axios": "^1.4.0",
83-
"bluebird": "^3.5.5",
8482
"lodash": "^4.17.11",
8583
"teen_process": "^4.0.7"
8684
},

0 commit comments

Comments
 (0)