@wdio/utils
Advanced tools
Comparing version 5.16.12 to 5.16.13
@@ -13,2 +13,3 @@ "use strict"; | ||
const log = (0, _logger.default)('@wdio/utils:shim'); | ||
let inCommandHook = false; | ||
let hasWdioSyncSupport = false; | ||
@@ -60,20 +61,34 @@ exports.hasWdioSyncSupport = hasWdioSyncSupport; | ||
let wrapCommand = async function (commandName, fn, ...args) { | ||
await executeHooksWithArgs.call(this, this.options.beforeCommand, [commandName, args]); | ||
let commandResult; | ||
let commandError; | ||
let wrapCommand = function wrapCommand(commandName, fn) { | ||
return async function wrapCommandFn(...args) { | ||
const beforeHookArgs = [commandName, args]; | ||
try { | ||
commandResult = await fn.apply(this, args); | ||
} catch (err) { | ||
commandError = err; | ||
} | ||
if (!inCommandHook) { | ||
inCommandHook = true; | ||
await executeHooksWithArgs.call(this, this.options.beforeCommand, beforeHookArgs); | ||
inCommandHook = false; | ||
} | ||
await executeHooksWithArgs.call(this, this.options.afterCommand, [commandName, args, commandResult, commandError]); | ||
let commandResult; | ||
let commandError; | ||
if (commandError) { | ||
throw commandError; | ||
} | ||
try { | ||
commandResult = await fn.apply(this, args); | ||
} catch (err) { | ||
commandError = err; | ||
} | ||
return commandResult; | ||
if (!inCommandHook) { | ||
inCommandHook = true; | ||
const afterHookArgs = [...beforeHookArgs, commandResult, commandError]; | ||
await executeHooksWithArgs.call(this, this.options.afterCommand, afterHookArgs); | ||
inCommandHook = false; | ||
} | ||
if (commandError) { | ||
throw commandError; | ||
} | ||
return commandResult; | ||
}; | ||
}; | ||
@@ -80,0 +95,0 @@ |
{ | ||
"name": "@wdio/utils", | ||
"version": "5.16.12", | ||
"version": "5.16.13", | ||
"description": "A WDIO helper utility to provide several utility functions used across the project.", | ||
@@ -40,3 +40,3 @@ "author": "Christian Bromann <christian@saucelabs.com>", | ||
}, | ||
"gitHead": "6bb593e8170fd9f7032fd0d1767147ce167d4c89" | ||
"gitHead": "d25c41d08c46c58a22282133d501990b652f34b7" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
29458
826