Evaluates the provided JavaScript condition expression. The function uses
eval, so frequent calls to it may impede performance.

@param {string} conditionCode A JavaScript expression to evaluate.
@param {Object<string, *>} variables The variables that should be available
to the expression to evaluate.
@return {boolean} The result of the evaluated expression, retyped to a
boolean.
function evaluateCondition(conditionCode, variables) {
  let trimmedCondition = conditionCode.trim();

  if ($Debug) {
    if (!/^!?('[^']*'|"[^"]*")$/.test(trimmedCondition)) {
      throw new Error('Invalid expected value: ' + trimmedCondition);
    }
  }

  let negate = trimmedCondition.charAt(0) === '!';

  let expectedValue = trimmedCondition.slice(negate ? 2 : 1, -1);

  return negate
    ? expectedValue !== variables.$Env
    : expectedValue === variables.$Env;
}