Skip to content

Commit

Permalink
Fix warnings when assertions are checked after execution
Browse files Browse the repository at this point in the history
  • Loading branch information
coditva committed Apr 2, 2024
1 parent f3946ba commit 19ca719
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/sandbox/postman-legacy-interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,8 @@ module.exports = {

const legacyAPIUsage = new Set();

scope.__is_deprecation_warning_enabled = true;

// wrap all globals to ensure we track their usage to show warnings
// on access.
LEGACY_GLOBS.forEach((key) => {
Expand All @@ -431,7 +433,7 @@ module.exports = {

globalvars[key] = new Proxy(globalvars[key], {
set (target, prop, value) {
logDeprecationWarning(key, legacyAPIUsage, console);
scope.__is_deprecation_warning_enabled && logDeprecationWarning(key, legacyAPIUsage, console);

target[prop] = value;
},
Expand All @@ -440,17 +442,17 @@ module.exports = {
// special handling for postman because setNextRequest is
// used a lot.
if (key === 'postman') {
logDeprecationWarning('postman.setNextRequest', legacyAPIUsage, console);
scope.__is_deprecation_warning_enabled && logDeprecationWarning('postman.setNextRequest', legacyAPIUsage, console);

Check failure on line 445 in lib/sandbox/postman-legacy-interface.js

View workflow job for this annotation

GitHub Actions / Lint

This line has a length of 139. Maximum allowed is 120
}
else {
logDeprecationWarning(key, legacyAPIUsage, console);
scope.__is_deprecation_warning_enabled && logDeprecationWarning(key, legacyAPIUsage, console);
}

return target[prop];
},

apply (target, thisArg, args) {
logDeprecationWarning(key, legacyAPIUsage, console);
scope.__is_deprecation_warning_enabled && logDeprecationWarning(key, legacyAPIUsage, console);

return target.apply(thisArg, args);
}
Expand Down Expand Up @@ -493,6 +495,8 @@ module.exports = {
return;
}

scope.__is_deprecation_warning_enabled = false;

raiseAssertionEvent(scope, pmapi, onAssertion);
},

Expand Down

0 comments on commit 19ca719

Please sign in to comment.