cosmiconfig
Advanced tools
Changelog
7.0.0
${moduleName}rc.cjs
and ${moduleName}.config.cjs
to the default searchPlaces
, to support users of "type": "module"
in recent versions of Node.Changelog
6.0.0
Breaking change: The package now has named exports. See examples below.
Breaking change: Separate async and sync APIs, accessible from different named exports. If you used explorer.searchSync()
or explorer.loadSync()
, you'll now create a sync explorer with cosmiconfigSync()
, then use explorerSync.search()
and explorerSync.load()
.
// OLD: cosmiconfig v5
import cosmiconfig from 'cosmiconfig';
const explorer = cosmiconfig('example');
const searchAsyncResult = await explorer.search();
const loadAsyncResult = await explorer.load('./file/to/load');
const searchSyncResult = explorer.searchSync();
const loadSyncResult = explorer.loadSync('./file/to/load');
// NEW: cosmiconfig v6
import { cosmiconfig, cosmiconfigSync } from 'cosmiconfig';
const explorer = cosmiconfig('example');
const searchAsyncResult = await explorer.search();
const loadAsyncResult = await explorer.load('./file/to/load');
const explorerSync = cosmiconfigSync('example');
const searchSyncResult = explorerSync.search();
const loadSyncResult = explorerSync.load('./file/to/load');
Breaking change: Remove support for Node 4 and 6. Requires Node 8+.
Breaking change: Use npm package yaml to parse YAML instead of npm package js-yaml.
Breaking change: Remove cosmiconfig.loaders
and add named export defaultLoaders
that exports the default loaders used for each extension.
import { defaultLoaders } from 'cosmiconfig';
console.log(Object.entries(defaultLoaders));
// [
// [ '.js', [Function: loadJs] ],
// [ '.json', [Function: loadJson] ],
// [ '.yaml', [Function: loadYaml] ],
// [ '.yml', [Function: loadYaml] ],
// [ 'noExt', [Function: loadYaml] ]
// ]
Migrate from Flowtype to Typescript.
Lazy load all default loaders.
Changelog
5.2.1
js-yaml
to avoid npm audit warning.Changelog
5.2.0
packageProp
values can be arrays of strings, to allow for property names that include periods. (This was possible before, but not documented or deliberately supported.)lodash.get
dependency with a locally defined function.js-yaml
to avoid npm audit warning.Changelog
5.1.0
packageProp
values can include periods to describe paths to nested objects within package.json
.Changelog
5.0.7
require
cache, fixing a bug where updates to .js
config files would not load even when Cosmiconfig was told not to cache.Changelog
5.0.6
Changelog
5.0.5
load
and loadSync
work with paths relative to process.cwd()
.Changelog
5.0.4
rc
files with .js
extensions included in default searchPlaces
.Changelog
5.0.3