Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// not connected to a development tool and is either a published app running in
// the Expo client, or a standalone app (we also assume production for a missing
// manifest, but that should never happen)
const IS_PRODUCTION = !Constants.manifest || !Constants.manifest.developer
// The app can still run in production "mode" in development environments, in which
// cases the global boolean __DEV__ will be set to true
const IS_PRODUCTION_MODE = typeof __DEV__ === 'undefined' || __DEV__ !== true
module.exports = {
logger: {
...schema.logger,
defaultValue: () => getPrefixedConsole()
},
releaseStage: {
...schema.releaseStage,
defaultValue: () => {
if (IS_PRODUCTION) return 'production'
if (IS_PRODUCTION_MODE) return 'local-prod'
return 'local-dev'
}
}
}
const getPrefixedConsole = () => {
return reduce([ 'debug', 'info', 'warn', 'error' ], (accum, method) => {
// console.error causes standalone expo apps to reload on android
// so don't do any logging that level – use console.warn instead
const consoleMethod = (IS_PRODUCTION && method === 'error') ? console.warn : console[method]
accum[method] = consoleMethod.bind(console, '[bugsnag]')
return accum
}, {})
projectRoot: {
defaultValue: () => process.cwd(),
validate: value => value === null || stringWithLength(value),
message: 'should be string'
},
hostname: {
defaultValue: () => os.hostname(),
message: 'should be a string',
validate: value => value === null || stringWithLength(value)
},
logger: {
...schema.logger,
defaultValue: () => getPrefixedConsole()
},
releaseStage: {
...schema.releaseStage,
defaultValue: () => process.env.NODE_ENV || 'production'
},
agent: {
defaultValue: () => undefined,
message: 'should be an HTTP(s) agent',
validate: value => value === undefined || isAgent(value)
},
onUncaughtException: {
defaultValue: () => (err, report, logger) => {
logger.error(`Uncaught exception${getContext(report)}, the process will now terminate…\n${(err && err.stack) ? err.stack : err}`)
process.exit(1)
},
message: 'should be a function',
validate: value => typeof value === 'function'
},
onUnhandledRejection: {