Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mopsgamer/config
Node.js config library for command-line tools with strict type check.
https://github.com/mopsgamer/config
Last synced: about 2 months ago
JSON representation
Node.js config library for command-line tools with strict type check.
- Host: GitHub
- URL: https://github.com/mopsgamer/config
- Owner: Mopsgamer
- Created: 2024-10-17T12:07:06.000Z (2 months ago)
- Default Branch: main
- Last Pushed: 2024-11-02T13:31:11.000Z (about 2 months ago)
- Last Synced: 2024-11-02T14:24:58.972Z (about 2 months ago)
- Language: TypeScript
- Homepage:
- Size: 242 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# @m234/config
[![npm version](https://img.shields.io/npm/v/@m234/config.svg?style=flat)](https://www.npmjs.com/package/@m234/config)
[![npm downloads](https://img.shields.io/npm/dm/@m234/config.svg?style=flat)](https://www.npmjs.com/package/@m234/config)
[![github](https://img.shields.io/github/stars/Mopsgamer/config.svg?style=flat)](https://github.com/Mopsgamer/config)
[![github issues](https://img.shields.io/github/issues/Mopsgamer/config.svg?style=flat)](https://github.com/Mopsgamer/config/issues)Node.js config library for command-line tools with strict type check.
## Features
- Type checks while loading the config.
## Install
```bash
npm i @m234/config
```## Usage
```ts
import {homedir} from "node:os"
import {exit} from "node:process"
import {join} from "node:path"
import {Config, Types as ConfigTypes} from "@m234/config"function exitFail(message: string | undefined) {
console.error(message)
process.exit(1)
}const cfg = new Config(join(homedir(), 'app.yaml'))
cfg.setValidator('name', Types.string())
exitFail(cfg.failLoad())console.log(cfg.get('name'))
```