How to use the cosmiconfig.cosmiconfigSync.explorer function in cosmiconfig

To help you get started, we’ve selected a few cosmiconfig 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 kentcdodds / babel-plugin-macros / src / __tests__ / index.js View on Github external
setup() {
        jest
          .spyOn(cosmiconfigSyncMock.explorer, 'search')
          .mockImplementationOnce(() => {
            throw new Error('this is a cosmiconfig error')
          })
        jest.spyOn(console, 'error').mockImplementationOnce(() => {})
        return function teardown() {
          try {
            expect(console.error).toHaveBeenCalledTimes(1)
            expect(console.error.mock.calls[0]).toMatchSnapshot()
            console.error.mockClear()
          } catch (e) {
            console.error(e)
            console.error.mockClear()
            throw e
          }
        }
      },
github kentcdodds / babel-plugin-macros / src / __tests__ / index.js View on Github external
setup() {
        jest
          .spyOn(cosmiconfigSyncMock.explorer, 'search')
          .mockImplementationOnce(() => {
            return null
          })
        return function teardown() {
          try {
            const configurableMacro = require('./fixtures/config/configurable.macro')
            expect(configurableMacro.realMacro).toHaveBeenCalledTimes(1)
            expect(configurableMacro.realMacro.mock.calls[0][0].config).toEqual(
              {},
            )
            configurableMacro.realMacro.mockClear()
          } catch (e) {
            console.error(e)
            throw e
          }
        }

cosmiconfig

Find and load configuration from a package.json property, rc file, TypeScript module, and more!

MIT
Latest version published 12 months ago

Package Health Score

83 / 100
Full package analysis