A minimalistic library for using JS configuration files, along with defaults passed as objects.
Supports both ESM and CommonJS module formats.
First off import the library. If using ES Modules:
import dotjs from '@lumjs/dotjs';Or if using CommonJS:
const dotjs = require('@lumjs/dotjs');Now that it's loaded, the sytax is the same.
const DEFAULT_OPTS = {someOption: true, anotherOption: false};
const config = await dotjs(DEFAULT_OPTS, 'config.defaults.js', 'config.js');It will ignore any files that don't exist. Also, all file paths are relative to the current working directory, so keep that in mind.
This library can be found in two places:
Timothy Totten 2010@totten.ca