UNPKG

appium-xcuitest-driver

Version:

Appium driver for iOS using XCUITest for backend

45 lines 1.57 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.tryLoadRemoteXPCModule = tryLoadRemoteXPCModule; exports.getLastRemoteXPCImportError = getLastRemoteXPCImportError; let cachedModule = null; let moduleUnavailable = false; let lastImportError = null; /** * Optionally load **appium-ios-remotexpc** (process-wide cache). * * Returns `null` when the package is missing or failed to import. Missing-package failures are * cached for the remainder of the process; transient import errors may succeed on a later call. */ async function tryLoadRemoteXPCModule() { if (cachedModule) { lastImportError = null; return cachedModule; } if (moduleUnavailable) { return null; } try { cachedModule = (await import('appium-ios-remotexpc')); lastImportError = null; return cachedModule; } catch (err) { const error = err; lastImportError = error; if (isAppiumIosRemotexpcPackageMissingError(error)) { moduleUnavailable = true; } return null; } } /** Last failed optional `import('appium-ios-remotexpc')`; cleared when a load succeeds. */ function getLastRemoteXPCImportError() { return lastImportError; } function isAppiumIosRemotexpcPackageMissingError(err) { const msg = err.message; return ((msg.includes('Cannot find module') && msg.includes('appium-ios-remotexpc')) || (msg.includes('Cannot find package') && msg.includes('appium-ios-remotexpc'))); } //# sourceMappingURL=module-loader.js.map