A zero-dependency alternative to cosmiconfig for loading configuration files
89
Build a command-line utility that helps developers migrate from Cosmiconfig to Lilconfig by verifying API compatibility and testing configuration loading behavior.
Your utility should:
Initialize explorers: Create both a Cosmiconfig explorer and a Lilconfig explorer for a given module name (e.g., "myapp")
Search for configuration: Implement a function that searches for configuration files starting from a specified directory using both explorers
Compare results: Compare the results from both explorers and verify they return equivalent data structures (filepath, config, isEmpty fields)
Test both sync and async: Implement the comparison for both synchronous and asynchronous search methods
Handle edge cases: Properly handle cases where:
compareExplorers(moduleName, searchFrom) that returns a comparison report objectcompareExplorersSync(moduleName, searchFrom) for synchronous comparisoncompatible boolean field and a details object with comparison resultsA zero-dependency alternative to cosmiconfig for loading configuration files.
Configuration file search and loading library (for comparison testing).
// test/config-migration.test.js
// Given a directory with a .myapprc.json file containing {"setting": "value"}
// When comparing async search results from both libraries
// Then both should return identical filepath and config values// test/config-migration.test.js
// Given a directory with a myapp.config.js file exporting {mode: "production"}
// When comparing sync search results from both libraries
// Then both should return identical filepath and config values// test/config-migration.test.js
// Given a directory with no configuration files
// When searching with both libraries (async)
// Then both should return nullInstall with Tessl CLI
npx tessl i tessl/npm-lilconfigdocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10