A zero-dependency alternative to cosmiconfig for loading configuration files
89
Build a tool that finds project-specific configuration files by searching up the directory tree from a given starting point.
Your tool should find configuration files for a hypothetical "devtools" project. The tool must:
.devtoolsrc.json - JSON format.devtoolsrc.js - JavaScript moduledevtools.config.js - JavaScript module.devtoolsrc.json file exists in the current directory, it finds and loads the configuration @test@generates
/**
* Creates a configuration finder for the specified tool name
* @param {string} toolName - The name of the tool to find config for
* @returns {Object} An explorer object with search methods
*/
function createConfigFinder(toolName) {
// Returns an object with search methods
}
/**
* Synchronously searches for a configuration file starting from searchFrom directory
* @param {string} [searchFrom] - Directory to start searching from (defaults to process.cwd())
* @returns {Object|null} Result object with filepath and config, or null if not found
*/
function searchSync(searchFrom) {
// Implementation here
}
/**
* Asynchronously searches for a configuration file starting from searchFrom directory
* @param {string} [searchFrom] - Directory to start searching from (defaults to process.cwd())
* @returns {Promise<Object|null>} Promise resolving to result object or null
*/
async function search(searchFrom) {
// Implementation here
}
module.exports = {
createConfigFinder
};Provides configuration file search and loading capabilities for Node.js applications.
Install 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