Class ScriptLoader

Lua script loader with include support



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


    • 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.


    • 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


    • 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 must be in camel case format.

    For example: moveToFinish-3.lua


    Returns Promise<Command[]>

  • Resolve the script path considering path mappings


    • scriptName: string

      the name of the script

    • stack: string[] = []

      the include stack, for nicer errors

    Returns string

Generated using TypeDoc