Skip to main content

Function Signature

export const getConfig = () => Record<string, any>

Description

Retrieves the entire configuration object from the ScryxCLI configuration file located at ~/.scrycli/config.json. This function reads the configuration file synchronously and returns the parsed JSON object.

Return Type

config
Record<string, any>
required
The complete configuration object containing all stored key-value pairs.

Usage

import { getConfig } from '@scryxcli/config';

const config = getConfig();
console.log(config);
// Output: { apiKey: 'abc123', theme: 'dark', verbose: true }

Examples

Get Entire Configuration

const config = getConfig();
console.log(config);

Access Specific Configuration Value

const config = getConfig();
const apiKey = config.apiKey;
const theme = config.theme;

console.log(`API Key: ${apiKey}`);
console.log(`Theme: ${theme}`);

Check if Configuration Key Exists

const config = getConfig();

if ('apiKey' in config) {
  console.log('API key is configured');
} else {
  console.log('API key not found');
}

Error Conditions

  • If the configuration file cannot be read, a filesystem error will be thrown
  • If the configuration file contains invalid JSON, a SyntaxError will be thrown

Notes

  • The configuration file is automatically created at ~/.scrycli/config.json if it doesn’t exist
  • This function performs synchronous file I/O operations
  • Returns an empty object {} if the configuration file is empty or newly created

Build docs developers (and LLMs) love