How to use the cosmiconfig.cosmiconfig 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 semantic-release / semantic-release / lib / get-config.js View on Github external
module.exports = async (context, opts) => {
  const {cwd, env} = context;
  const {config, filepath} = (await cosmiconfig(CONFIG_NAME, {searchPlaces: CONFIG_FILES}).search(cwd)) || {};

  debug('load config from: %s', filepath);

  // Merge config file options and CLI/API options
  let options = {...config, ...opts};
  if (options.ci === false) {
    options.noCi = true;
  }

  const pluginsPath = {};
  let extendPaths;
  ({extends: extendPaths, ...options} = options);
  if (extendPaths) {
    // If `extends` is defined, load and merge each shareable config with `options`
    options = {
      ...castArray(extendPaths).reduce((result, extendPath) => {
github sw-yx / egghead-cli-workshop / cli / packages / mycli / src / base.ts View on Github external
import { Command } from "@oclif/command";
const { cosmiconfig } = require("cosmiconfig");
const explorer = cosmiconfig("mycli");
var debug = require("debug")("mycli:base");
type ConfigType = {
  name?: string;
};

const updateNotifier = require("update-notifier");
const pkg = require("../package.json");

export default abstract class Base extends Command {
  static config: null | ConfigType;
  async init() {
    const notifier = updateNotifier({
      pkg,
      updateCheckInterval: 1000,
      shouldNotifyInNpmScript: true
    });
github ematipico / terraform-nextjs-plugin / bin / terranext.js View on Github external
#!/usr/bin/env node

const { cosmiconfig } = require("cosmiconfig");
const meow = require("meow");
const generateResources = require("../src");

const explorer = cosmiconfig("terranext");

const cli = meow(
	`
Usage
	$ terranext

Options
	--gateway-key, -g   The API Gateway key of the project. Default is "Terranext"
	--next-app-dir, -d  The path that Terraform CLI has to follow to reach the nextjs project.
	--provider          The Cloud provider to use when exporting the configuration
	--env								A way for passing environment variables to the lambdas
		
Examples
	$ terranext 
	$ terranext --gateway-key=CustomKey --next-app-dir=../../nextjs-project/
	$ terranext --provider=AWS --next-app-dir=../../nextjs-project/
github linkedin / css-blocks / packages / @css-blocks / config / src / index.ts View on Github external
async function _load(configPath: string, transform: Transform): Promise> {
  let loader = cosmiconfig("css-blocks", {
    transform,
  });
  let result = await loader.load(configPath);
  return result!.config as Partial;
}
github mAAdhaTTah / brookjs / packages / brookjs-cli / src / cli / App.tsx View on Github external
async run(
    argv: string[],
    {
      stdin = process.stdin,
      stdout = process.stdout,
      cwd = process.cwd(),
      debug = false
    }: {
      stdin?: typeof process.stdin;
      stdout?: typeof process.stdout;
      cwd?: string;
      debug?: boolean;
    } = {}
  ) {
    let rc: Maybe = null;
    const result = await cosmiconfig(this.name, { loaders }).search();

    if (result != null) {
      rc = RC.decode(result.config).fold(
        es => new RCError(es),
        value => value as RC
      );
    }

    const { command, args } = this.commands.get(argv);

    const instance = render(
      
        
      ,
      {
        stdout,
github compodoc / compodoc / src-refactored / core / use-cases / handle-config.ts View on Github external
constructor() {
        this.configExplorer = cosmiconfig(this.cosmiconfigModuleName);
    }
github linkedin / css-blocks / packages / @css-blocks / config / src / index.ts View on Github external
export async function search(searchDirectory?: string): Promise | null> {
  let loader = cosmiconfig("css-blocks", {
    transform: transformFinal,
    searchPlaces: [
      "package.json",
      "css-blocks.config.json",
      "css-blocks.config.js",
    ],
  });
  let result = await loader.search(searchDirectory);
  return result && result.config as Partial;
}
github ematipico / terraform-nextjs-plugin / src / index.js View on Github external
async function retrieveConfiguration() {
	const explorer = cosmiconfig("terranext");
	try {
		const result = await explorer.search();
		return result.config;
	} catch (error) {
		return undefined;
	}
}

cosmiconfig

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

MIT
Latest version published 11 months ago

Package Health Score

83 / 100
Full package analysis