How to use the bs-logger.LogContexts.namespace function in bs-logger

To help you get started, we’ve selected a few bs-logger examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kulshekhar / ts-jest / src / config / paths-to-module-name-mapper.ts View on Github external
import { LogContexts } from 'bs-logger'
import { CompilerOptions } from 'typescript'

import { rootLogger } from '../util/logger'
import { Errors, interpolate } from '../util/messages'

type TsPathMapping = Exclude
type JestPathMapping = jest.InitialOptions['moduleNameMapper']

// we don't need to escape all chars, so commented out is the real one
// const escapeRegex = (str: string) => str.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&')
const escapeRegex = (str: string) => str.replace(/[-\\^$*+?.()|[\]{}]/g, '\\$&')

const logger = rootLogger.child({ [LogContexts.namespace]: 'path-mapper' })

export const pathsToModuleNameMapper = (
  mapping: TsPathMapping,
  { prefix = '' }: { prefix?: string } = {},
): JestPathMapping => {
  const jestMap: JestPathMapping = {}
  for (const fromPath of Object.keys(mapping)) {
    let pattern: string
    const toPaths = mapping[fromPath]
    // check that we have only one target path
    if (toPaths.length === 0) {
      logger.warn(interpolate(Errors.NotMappingPathWithEmptyMap, { path: fromPath }))
      continue
    } else if (toPaths.length > 1) {
      logger.warn(
        interpolate(Errors.MappingOnlyFirstTargetOfPath, {
github kulshekhar / ts-jest / src / util / backports.ts View on Github external
import { LogContexts, Logger } from 'bs-logger'

import { Deprecateds, Helps, interpolate } from './messages'

const context = { [LogContexts.namespace]: 'backports' }

/**
 * @internal
 */
export const backportJestConfig = (
  logger: Logger,
  config: T,
): T => {
  logger.debug({ ...context, config }, 'backporting config')

  const { globals = {} } = (config || {}) as any
  const { 'ts-jest': tsJest = {} } = globals as any
  const mergeTsJest: any = {}
  let hadWarnings = false
  const warnConfig = (oldPath: string, newPath: string, note?: string) => {
    hadWarnings = true
github kulshekhar / ts-jest / src / config / config-set.ts View on Github external
constructor(jestConfig: jest.ProjectConfig, readonly parentOptions?: TsJestGlobalOptions, parentLogger?: Logger) {
    this._jestConfig = jestConfig
    this.logger = parentLogger ? parentLogger.child({ [LogContexts.namespace]: 'config' }) : logger
  }