How to use the pkg-conf.sync function in pkg-conf

To help you get started, we’ve selected a few pkg-conf 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 jxnblk / ok-mdx / cli.js View on Github external
// const log = require('./lib/log')

const log = (...args) => {
  console.log(
    chalk.cyan('[mdx]'),
    ...args
  )
}
log.error = (...args) => {
  console.log(
    chalk.red('[err]'),
    ...args
  )
}

const config = require('pkg-conf').sync('ok-mdx')

const cli = meow(`
  Usage:

    $ mdx docs

  Options:

    -o --open     Opens development server in default browser
    -p --port     Port for development server
    --vim         Enable editor Vim mode

`, {
  flags: {
    open: {
      type: 'boolean',
github traveloka / javascript / packages / marlint / lib / getOptionsForPath.js View on Github external
const absolutePath =
    filePath.charAt(0) === '/' ? filePath : path.resolve(cwd, filePath);

  if (absolutePath.indexOf('/packages/') === -1) {
    // Not a lerna package, use single package.json
    const packageOptions = pkgConf.sync('marlint', { cwd });
    return buildOptions(packageOptions, runtimeOptions);
  }

  // Get lerna root directory and package root directory to find specific config
  // in package.json. Package specific config will overrides root specific config
  const [rootLernaDir, relativeFilePath] = absolutePath.split('/packages/');
  const [packageName, ..._] = relativeFilePath.split('/');
  const packageDir = `${rootLernaDir}/packages/${packageName}`;

  const packageConfig = pkgConf.sync('marlint', { cwd: packageDir });
  const rootConfig = pkgConf.sync('marlint', { cwd: rootLernaDir });
  const packageOptions = merge({}, rootConfig, packageConfig);

  return buildOptions(packageOptions, runtimeOptions);
}
github SwellRT / swellrt / pad / node_modules / lite-server / node_modules / browser-sync / node_modules / yargs / yargs.js View on Github external
function parseArgs (args, shortCircuit) {
    options.__ = y18n.__
    options.configuration = pkgConf.sync('yargs', {
      defaults: {},
      cwd: requireMainFilename(require)
    })
    const parsed = Parser.detailed(args, options)
    const argv = parsed.argv
    var aliases = parsed.aliases

    argv.$0 = self.$0
    self.parsed = parsed

    guessLocale() // guess locale lazily, so that it can be turned off in chain.

    // while building up the argv object, there
    // are two passes through the parser. If completion
    // is being performed short-circuit on the first pass.
    if (shortCircuit) {
github ranjithprabhuk / ng2-Dashboard / node_modules / yargs / yargs.js View on Github external
function parseArgs (args, shortCircuit) {
    options.__ = y18n.__
    options.configuration = pkgConf.sync('yargs', {
      defaults: {},
      cwd: requireMainFilename(require)
    })
    const parsed = Parser.detailed(args, options)
    const argv = parsed.argv
    var aliases = parsed.aliases

    argv.$0 = self.$0
    self.parsed = parsed

    guessLocale() // guess locale lazily, so that it can be turned off in chain.

    // while building up the argv object, there
    // are two passes through the parser. If completion
    // is being performed short-circuit on the first pass.
    if (shortCircuit) {
github walrusjs / walrus / packages / walrus-plugin-eslint / src / linter.ts View on Github external
const self = this;

    if (opts) {
      opts = {};
    }
    opts = Object.assign({}, opts);
    opts.eslintConfig = Object.assign({}, self.eslintConfig);
    opts.eslintConfig.fix = !!opts.fix;

    if (!opts.cwd) opts.cwd = self.cwd;

    // 如果未提供usePackageJson选择,默认为true
    const usePackageJson = !_.isNil(opts.usePackageJson) ? opts.usePackageJson : true;

    // package.json中的配置
    const packageOpts = usePackageJson ? pkgConf.sync(self.cmd, { cwd: opts.cwd }) : {};

    // ignore
    if (!opts.ignore) opts.ignore = [];
    addIgnore(packageOpts.ignore);
    if (!packageOpts.noDefaultIgnore) {
      addIgnore(DEFAULT_IGNORE);
    }

    // globals
    addGlobals(packageOpts.globals || packageOpts.global);
    addGlobals(opts.globals || opts.global);

    // plugins
    addPlugins(packageOpts.plugins || packageOpts.plugin);
    addPlugins(opts.plugins || opts.plugin);
github xojs / xo / lib / options-manager.js View on Github external
const mergeWithPackageConfig = options => {
	options = {
		cwd: process.cwd(),
		...options
	};

	options.cwd = path.resolve(options.cwd);
	const config = pkgConf.sync('xo', {cwd: options.cwd, skipOnFalse: true});
	const engines = pkgConf.sync('engines', {cwd: options.cwd});

	return {
		...config,
		nodeVersion: engines && engines.node && semver.validRange(engines.node),
		...options
	};
};
github c8r / kit / cli / cli.js View on Github external
#!/usr/bin/env node
'use strict'

const fs= require('fs')
const path = require('path')
const importJsx = require('import-jsx')
const { h, render } = require('ink')
const meow = require('meow')
const open = require('react-dev-utils/openBrowser')
const log = require('@compositor/log')
const chalk = require('chalk')
const clipboard = require('clipboardy')
const findup = require('find-up')
const config = require('pkg-conf').sync('kit')

const Init = importJsx('./src/Init')
const parseArgs = require('./lib/parse-args')

const cli = meow(`
  Usage

    $ kit  [options]

  Examples
    $ kit examples
    $ kit dev examples
    $ kit init

  Options
github avajs / ava / lib / babel-pipeline.js View on Github external
function hashPartialTestConfig({babelrc, config, options: {plugins, presets}}, projectDir, pluginAndPresetHashes) {
	const inputs = [];
	if (babelrc) {
		inputs.push(babelrc);

		const filename = path.basename(babelrc);
		if (filename === 'package.json') {
			inputs.push(JSON.stringify(pkgConf.sync('babel', {cwd: path.dirname(filename)})));
		} else {
			inputs.push(stripBomBuf(fs.readFileSync(babelrc)));
		}
	}

	if (config) {
		inputs.push(config, stripBomBuf(fs.readFileSync(config)));
	}

	for (const item of [...plugins, ...presets]) {
		if (!item.file) {
			continue;
		}

		const {file: {resolved: filename}} = item;
		if (pluginAndPresetHashes.has(filename)) {
github c8r / x0 / cli.js View on Github external
#!/usr/bin/env node
const fs = require('fs')
const path = require('path')
const meow = require('meow')
const findup = require('find-up')
const readPkg = require('read-pkg-up').sync
const openBrowser = require('react-dev-utils/openBrowser')
const log = require('@compositor/log')
const chalk = require('chalk')
const clipboard = require('clipboardy')

const config = require('pkg-conf').sync('x0')
const pkg = readPkg().pkg

log.name = 'x0'

const cli = meow(`
  ${chalk.gray('Usage')}

    ${chalk.gray('Dev Server')}

      ${chalk.cyan('x0 pages')}

    ${chalk.gray('Build')}

      ${chalk.cyan('x0 build pages')}

  ${chalk.gray('Options')}
github dempfi / ava-playback / src / index.ts View on Github external
import * as fs from 'fs'
import * as path from 'path'
import * as config from 'pkg-conf'
import playback from './playback'
import record from './record'

const avaConfing = config.sync<{ playbacks?: string }>('ava', { defaults: { playbacks: 'playbacks' } })
const projectPath = path.dirname(config.filepath(avaConfing))
const playbacksPath = path.join(projectPath, avaConfing.playbacks)

if (!fs.existsSync(playbacksPath)) fs.mkdirSync(playbacksPath)

const mode = process.env.AVA_PLAYBACK
if (mode === 'record') record(playbacksPath)
if (mode === 'play') playback(playbacksPath)

pkg-conf

Get namespaced config from the closest package.json

MIT
Latest version published 1 year ago

Package Health Score

58 / 100
Full package analysis

Popular pkg-conf functions