import { Constants } from 'expo-constants';

import Logs from '../logs/Logs';
import RemoteLogging from '../logs/RemoteLogging';

if (Constants.manifest && Constants.manifest.logUrl) {
  // Enable logging to the Expo dev tools only if this JS is not running in a web browser (ex: the
  // remote debugger)
  if (!navigator.hasOwnProperty('userAgent')) {
    Logs.enableExpoCliLogging();
  } else {
    RemoteLogging.enqueueRemoteLogAsync('info', {}, [
      'You are now debugging remotely; check your browser console for your application logs.',
    ]);
  }
}

// NOTE(2018-10-29): temporarily filter out cyclic dependency warnings here since they are noisy and
// each warning symbolicates a stack trace, which is slow when there are many warnings
const originalWarn = console.warn;
console.warn = function warn(...args) {
  if (
    args.length > 0 &&
    typeof args[0] === 'string' &&
    /^Require cycle: .*\/node_modules\//.test(args[0])
  ) {
    return;
  }
  originalWarn.apply(console, args);
};

import { Constants } from 'expo-constants';

import Logs from '../logs/Logs';
import RemoteLogging from '../logs/RemoteLogging';

if (Constants.manifest && Constants.manifest.logUrl) {
  // Enable logging to the Expo dev tools only if this JS is not running in a web browser (ex: the
  // remote debugger)
  if (!navigator.hasOwnProperty('userAgent')) {
    Logs.enableExpoCliLogging();
  } else {
    RemoteLogging.enqueueRemoteLogAsync('info', {}, [
      'You are now debugging remotely; check your browser console for your application logs.',
    ]);
  }
}

// NOTE(2018-10-29): temporarily filter out cyclic dependency warnings here since they are noisy and
// each warning symbolicates a stack trace, which is slow when there are many warnings
const originalWarn = console.warn;
console.warn = function warn(...args) {
  if (
    args.length > 0 &&
    typeof args[0] === 'string' &&
    /^Require cycle: .*node_modules\//.test(args[0])
  ) {
    return;
  }
  originalWarn.apply(console, args);
};

Remove slash before the "node_modules" string in "Require cycle" warn message regex
Remove slash before the "node_modules" string in "Require cycle" warn message regex

Previous regex doesn't match any of "Require cycle" warns as they all contain not absolute warned modules path, but relative to project directory and without starting slash. 

Example warn message "Require cycle: node_modules/react-native-gesture-handler/GestureHandler.js -> node_modules/react-native-gesture-handler/Swipeable.js -> node_modules/react-native-gesture-handler/GestureHandler.js"