How to use the joycon 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 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 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) {

joycon

Load config with ease.

MIT
Latest version published 2 years ago

Package Health Score

67 / 100
Full package analysis

Popular joycon functions