How to use joycon - 10 common examples

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 takeoff-env / takeoff / src / lib / init-env / read-takeoff-file.ts View on Github external
export = (cwd: string): TakeoffFileData => {
  const loadTakeoffFile = new JoyCon({
    // Stop reading at parent dir
    // i.e. Only read file from process.cwd()
    cwd,
    stopDir: dirname(process.cwd()),
  });

  const { path: filepath, data } = loadTakeoffFile.loadSync(['takeoff.md']);
  if (!filepath) {
    return null;
  }

  return { filepath, tasks: parseMarkdown(data) };
};
github shuidi-fed / vuese / packages / cli / lib / index.ts View on Github external
import cac from 'cac'
import JoyCon from 'joycon'
import fs from 'fs-extra'
import { BabelParserPlugins } from '@vuese/parser'
import Log from 'log-horizon'
import preview from './preview'
import genDocute from './genDocute'
import genMarkdown from './genMarkdown'
import server from './server'

// Gotta fix after https://github.com/tabrindle/envinfo/pull/105 gets merged (type-definitions)
const envinfo = require('envinfo')

const logger = Log.create()
const cli = cac()
const joycon = new JoyCon({
  packageKey: 'vuese'
})
joycon.addLoader({
  test: /\.vueserc$/,
  async load(filePath) {
    const source = await fs.readFile(filePath, 'utf-8')
    return JSON.parse(source)
  }
})

export type CliOptions = {
  include: string | string[]
  exclude: string | string[]
  outDir: string
  markdownDir: string
  markdownFile: string
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 / bili / src / config-loader.ts View on Github external
import path from 'path'
import fs from 'fs'
import JoyCon from 'joycon'
import requireFromString from 'require-from-string'

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

configLoader.addLoader({
  test: /\.[jt]s$/,
  loadSync(id) {
    const content = require('@babel/core').transform(
      fs.readFileSync(id, 'utf8'),
      {
        babelrc: false,
        configFile: false,
        filename: id,
        presets: [
          [
            require('@babel/preset-env'),
            {
github cacjs / cac / src / Cac.ts View on Github external
this.bin = bin || (process.argv[1] ? path.basename(process.argv[1]) : 'cli')
    this.commands = []
    this.options = new Options()
    this.extraHelps = []

    if (typeof defaultOpts === 'boolean') {
      this.helpOpt = defaultOpts
      this.versionOpt = defaultOpts
    } else if (typeof defaultOpts === 'object') {
      this.helpOpt = defaultOpts.help !== false
      this.versionOpt = defaultOpts.version !== false
    }

    this.pkg = Object.assign(
      {},
      pkg || new JoyCon({ files: ['package.json'], cwd: parentDir }).loadSync().data
    )

    if (this.versionOpt) {
      this.option('version', {
        desc: 'Display version',
        alias: 'v',
        type: 'boolean'
      })
    }
    if (this.helpOpt) {
      this.option('help', {
        desc: `Display help (You're already here)`,
        alias: 'h',
        type: 'boolean'
      })
    }
github egoist / vue-compile / src / index.ts View on Github external
constructor(options: InputOptions) {
    super()

    if (options.config !== false) {
      const joycon = new JoyCon({
        files: [
          typeof options.config === 'string'
            ? options.config
            : 'vue-compile.config.js'
        ],
        stopDir: path.dirname(process.cwd())
      })
      const { data: config, path: configPath } = joycon.loadSync()

      if (configPath) {
        debug(`Using config file: ${configPath}`)
      }

      options = { ...options, ...config}
    }
github walrusjs / walrus / packages / walrus-shared-utils / src / config-loader.ts View on Github external
import { dirname } from 'path';
import { readFileSync } from 'fs';
import JoyCon from 'joycon';

const requireFromString = require('require-from-string');

const configLoader = new JoyCon({
  stopDir: dirname(process.cwd())
});

configLoader.addLoader({
  test: /\.[jt]s$/,
  loadSync(id) {
    const content = require('@babel/core').transform(readFileSync(id, 'utf8'), {
      babelrc: false,
      configFile: false,
      filename: id,
      presets: [
        [
          require('@babel/preset-env'),
          {
            targets: {
              node: 'current'
github takeoff-env / takeoff / src / lib / load-rc-file.ts View on Github external
function loadRcFile(cwd: string): TakeoffRcFile {
  const loadTakeoffRc = new JoyCon({
    cwd,
  });

  let properties: Map = new Map();

  const { path: filepath, data } = loadTakeoffRc.loadSync(['.takeoffrc', '.takeoffrc.json']);

  if (!filepath) {
    return { exists: false, properties, rcRoot: '' };
  }

  if (filepath && typeof data === 'string' && data.charAt(0) === '{') {
    try {
      const result = JSON.parse(data);
      Object.keys(result).forEach((key: string) => properties.set(key, result[key]));
    } catch (e) {
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)

joycon

Load config with ease.

MIT
Latest version published 3 years ago

Package Health Score

67 / 100
Full package analysis

Popular joycon functions