ConfigStub: {
    contents?: ConfigContents;
    readFn?: (() => Promise<ConfigContents>);
    retrieveContents?: (() => Promise<JsonMap>);
    writeFn?: ((contents?) => Promise<void>);
}

Different hooks into ConfigFile used for testing instead of doing file IO.

Type declaration

  • Optional contents?: ConfigContents

    The contents that are used with @{link ConfigFile.readSync} and @{link ConfigFile.read}. If retrieveContents is set, it will use that instead of @{link ConfigFile.read} but NOT @{link ConfigFile.readSync}. This will also contain the new config when @{link ConfigFile.write} or @{link ConfigFile.writeSync} is called. This will persist through config instances, such as Alias.update and Alias.fetch.

  • Optional readFn?: (() => Promise<ConfigContents>)

    readFn A function that controls all aspect of ConfigFile.read. For example, it won't set the contents unless explicitly done. Only use this if you know what you are doing. Use retrieveContents instead.

  • Optional retrieveContents?: (() => Promise<JsonMap>)

    A function to conditionally read based on the config instance. The this value will be the config instance.

      • (): Promise<JsonMap>
      • Returns Promise<JsonMap>

  • Optional writeFn?: ((contents?) => Promise<void>)

    A function that controls all aspects of ConfigFile.write. For example, it won't read the contents unless explicitly done. Only use this if you know what you are doing. Use updateContents instead.

      • (contents?): Promise<void>
      • Parameters

        • Optional contents: AnyJson

        Returns Promise<void>