Class ScriptLoader

Lua script loader with include support

Constructors

Methods

  • Add a script path mapping. Allows includes of the form "/utils.lua" where includes is a user defined path

    Parameters

    • name: string

      the name of the mapping. Note: do not include angle brackets

    • mappedPath: string

      if a relative path is passed, it's relative to the caller of this function. Mapped paths are also accepted, e.g. "~/server/scripts/lua" or "/includes"

    Returns void

  • Construct the final version of a file by interpolating its includes in dependency order.

    Parameters

    • file: ScriptMetadata

      the file whose content we want to construct

    • Optional processed: Set<string>

      a cache to keep track of which includes have already been processed

    Returns string

  • Attach all lua scripts in a given directory to a client instance

    Parameters

    • client: RedisClient

      redis client to attach script to

    • pathname: string

      the path to the directory containing the scripts

    • Optional cache: Map<string, ScriptMetadata>

    Returns Promise<void>

  • Load redis lua scripts. The name of the script must have the following format:

    cmdName-numKeys.lua

    cmdName must be in camel case format.

    For example: moveToFinish-3.lua

    Parameters

    Returns Promise<Command[]>

  • Resolve the script path considering path mappings

    Parameters

    • scriptName: string

      the name of the script

    • stack: string[] = []

      the include stack, for nicer errors

    Returns string

Generated using TypeDoc