How to use the joycon.default function in joycon

To help you get started, we’ve selected a few joycon 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 saberland / saber / packages / saber / src / utils / configLoader.js View on Github external
// @ts-check
const path = require('path')
const fs = require('fs')
const JoyCon = require('joycon').default

const joycon = new JoyCon({
  stopDir: path.dirname(process.cwd())
})

joycon.addLoader({
  test: /\.ya?ml$/,
  loadSync: filepath =>
    require('./yaml.min').safeLoad(fs.readFileSync(filepath, 'utf8'))
})

joycon.addLoader({
  test: /\.toml$/,
  loadSync: filepath =>
    require('./toml.min').parse(fs.readFileSync(filepath, 'utf8'))
})

module.exports = {
github egoist / svg-to-vue-component / loader.js View on Github external
function loadSvgoConfig(cwd) {
  const joycon = new JoyCon()

  const readFile = promisify(fs.readFile)

  joycon.addLoader({
    test: /\.yml$/,
    async load(filepath) {
      const content = await readFile(filepath, 'utf8')
      return require('js-yaml').safeLoad(content)
    }
  })

  return joycon
    .load(
      ['.svgo.yml', '.svgo.js', '.svgo.json'],
      cwd,
      path.dirname(process.cwd())
github egoist / poi / core / poi / lib / utils / createConfigLoader.js View on Github external
module.exports = cwd => {
  const configLoader = new JoyCon({ cwd, stopDir: path.dirname(process.cwd()) })

  configLoader.addLoader(rcLoader)
  configLoader.addLoader(tsLoader)

  return {
    load(opts, noCache) {
      if (noCache) {
        configLoader.clearCache()
      }
      return configLoader.loadSync(opts)
    },
    resolve(opts, noCache) {
      if (noCache) {
        configLoader.clearCache()
      }
      return configLoader.resolveSync(opts)
github saojs / sao / lib / loadConfig.js View on Github external
const path = require('path')
const JoyCon = require('joycon').default

const joycon = new JoyCon({
  files: ['saofile.js', 'saofile.json']
})

module.exports = cwd =>
  joycon.load({
    cwd,
    stopDir: path.dirname(cwd)
  })

module.exports.hasConfig = cwd => {
  return joycon.resolve({
    cwd,
    stopDir: path.dirname(cwd)
  })
}
github upash / peco / lib / utils / config.js View on Github external
const path = require('upath')
const fs = require('fs-extra')
const JoyCon = require('joycon').default

const config = new JoyCon({
  stopDir: path.dirname(process.cwd())
})

config.addLoader({
  test: /\.yml$/,
  loadSync(filepath) {
    const yaml = require('js-yaml')
    const content = fs.readFileSync(filepath, 'utf8')
    return yaml.load(content)
  },
  async load(filepath) {
    const yaml = require('js-yaml')
    const content = await fs.readFile(filepath, 'utf8')
    return yaml.load(content)
  }
})

joycon

Load config with ease.

MIT
Latest version published 3 years ago

Package Health Score

67 / 100
Full package analysis

Popular joycon functions