cosmic

🌌 Find and load configuration for your app, based on cosmiconfig

View the Project on GitHub AnandChowdhary/cosmic

🌌 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:

For example, if the app name is β€œcosmic”, these files will be searched:

Apart from these, it also looks for:

πŸ’‘ 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