Options
All
  • Public
  • Public/Protected
  • All
Menu

node-dotconfig

Index

Functions

createConfig

  • createConfig(file: string, data: ConfigData): Promise<void>
  • Creates a configuration 'ini' file in the user's home directory.

    Example:

    import { createConfig } from 'node-dotconfig';
    
    async function main() {
     await createConfig('.my-app', { name: 'john', lastname: 'doe' });
    }

    Parameters

    • file: string

      config file name

    • data: ConfigData

      config object to save

    Returns Promise<void>

deleteConfig

  • deleteConfig(file: string): Promise<void>
  • Deletes a configuration file in the user's home directory

    Example:

    import { deleteConfig } from 'node-dotconfig';
    
    async function main() {
     await deleteConfig('.my-app');
    }

    Throws exception on file not found

    Parameters

    • file: string

      config file name

    Returns Promise<void>

readConfig

  • Loads a configuration file from the user's home directory.

    Example:

    import { readConfig } from 'node-dotconfig';
    
    async function main() {
     const config = await readConfig('.my-app');
     console.log(config.name);
    }

    Throws exception on file not found

    Parameters

    • name: string

      config file name

    Returns Promise<ConfigData>

updateConfig

  • updateConfig(file: string, data: ConfigData): Promise<void>
  • Patches a configuration file with a partial update

    Example:

    import { updateConfig } from 'node-dotconfig';
    
    async function main() {
     await updateConfig('.my-app', { lastname: 'einstein' });
    }

    Throws exception on file not found

    Parameters

    • file: string

      config file name

    • data: ConfigData

      partial update object

    Returns Promise<void>

Generated using TypeDoc