You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@anandchowdhary/cosmic

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@anandchowdhary/cosmic

Find and load configuration for your app, based on cosmiconfig

1.0.1
latest
Source
npmnpm
Version published
Weekly downloads
12
-7.69%
Maintainers
1
Weekly downloads
 
Created
Source

🌌 Cosmic

Find and load configuration for your app, based on cosmiconfig, with fallback to environment variables.

Node CI Travis CI Coverage Dependencies License Vulnerabilities Based on Node.ts npm type definitions npm package npm downloads Contributors semantic-release

npm

⭐ Features

Cosmic, like cosmiconfig, will look for a configuration file:

  • a package.json property
  • a JSON or YAML, extensionless "rc file"
  • an "rc file" with the extensions .json, .yaml, .yml, or .js.
  • a .config.js CommonJS module

For example, if the app name is "cosmic", these files will be searched:

  • a cosmic property in package.json
  • a .cosmicrc file in JSON or YAML format
  • a .cosmicrc.json file
  • a .cosmicrc.yaml, .cosmicrc.yml, or .cosmicrc.js file
  • a cosmic.config.js file exporting a JS object

Apart from these, it also looks for:

  • a cosmic.yaml, cosmic.yml, or cosmic.js file without "rc"
  • Environment variables

💡 Usage

Install the package from npm:

npm install @anandchowdhary/cosmic

Import and use:

import { cosmic } from "@anandchowdhary/cosmic";

const config = await cosmic("project"); // {}

Use the config function to fetch a value:

import { cosmic, config } from "@anandchowdhary/cosmic";

await cosmic("project");
const environment = config("nodeEnv");

Clear the cache and fetch configuration available:

import { clearCosmicCache } from "@anandchowdhary/cosmic";

clearCosmicCache();

Sync functions are also available:

import { cosmicSync } from "@anandchowdhary/cosmic";

const config = cosmicSync("project"); // {}

👩‍💻 Development

Build TypeScript:

npm run build

Run unit tests and view coverage:

npm run test-without-reporting

📄 License

MIT © Anand Chowdhary

Keywords

node.js

FAQs

Package last updated on 08 Sep 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts