CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-lilconfig

A zero-dependency alternative to cosmiconfig for loading configuration files

89

1.21x
Overview
Eval results
Files

task.mdevals/scenario-9/

Configuration File Loader

A utility that loads configuration files from specified file paths and returns the parsed configuration data.

Capabilities

Load configuration from file path

  • When given an absolute path to a JSON configuration file, it loads and returns the configuration with the file path @test
  • When given a relative path to a configuration file, it resolves the path and loads the configuration @test
  • When loading a JavaScript (.js) configuration file, it correctly loads and returns the exported configuration @test

Handle loading errors

  • When given a path to a non-existent file, it returns null @test
  • When given an empty string as the file path, it throws an error @test

Implementation

@generates

API

/**
 * Loads a configuration file from the specified path.
 *
 * @param {string} filepath - The path to the configuration file
 * @returns {Promise<Object|null>} A promise that resolves to an object with { config, filepath } if successful, or null if not found
 * @throws {Error} Throws an error if filepath is an empty string
 */
async function loadConfigFile(filepath) {
  // IMPLEMENTATION HERE
}

module.exports = { loadConfigFile };

Dependencies { .dependencies }

lilconfig { .dependency }

Provides configuration file search and loading capabilities.

Install with Tessl CLI

npx tessl i tessl/npm-lilconfig

tile.json