@jsheaven/read-config-file
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

@jsheaven/read-config-file

Tiny library to read config files like your.config.js, your.config.mjs, your.config.ts, your.conifg.json or your.config.json5 from disk.

User Stories

  1. As a developer, I want to read config files for my project/library/framework
  2. As a developer, I don't want to write that code again and again

Features

  • Reads and evalutates config files from disk: .js, .mjs, .ts, .json and .json5
  • Available as a simple API and simple to use CLI
  • Just 636 bytes nano sized (ESM, gizpped)
  • Tree-shakable and side-effect free
  • Runs on Windows, Mac, Linux, CI tested
  • First class TypeScript support
  • 100% Unit Test coverage

Example usage (CLI)

NODE_OPTIONS='--experimental-vm-modules' npx @jsheaven/read-config-file --config ./test/some.config.ts

You need at least version 18 of Node.js installed.

Example usage (API, as a library)

Setup
  • yarn: yarn add @jsheaven/read-config-file
  • npm: npm install @jsheaven/read-config-file

ESM
import { readConfigFile } from '@jsheaven/read-config-file'

const result = await readConfigFile({
  configFilePath: './test/some.config.ts',
})

CommonJS
const { readConfigFile } = require('@jsheaven/read-config-file')

// same API like ESM variant

Readme

Keywords

Package Sidebar

Install

npm i @jsheaven/read-config-file

Weekly Downloads

1

Version

1.0.1

License

MIT

Unpacked Size

67.3 kB

Total Files

23

Last publish

Collaborators

  • mansi1
  • kyr0