MCPcopy
hub / github.com/OptimalBits/bull / load

Method load

lib/commands/script-loader.js:399–418  ·  view source on GitHub ↗

* Attach all lua scripts in a given directory to a client instance * @param client - redis client to attach script to * @param pathname - the path to the directory containing the scripts

(client, pathname, cache)

Source from the content-addressed store, hash-verified

397 * @param pathname - the path to the directory containing the scripts
398 */
399 async load(client, pathname, cache) {
400 let paths = this.clientScripts.get(client);
401 if (!paths) {
402 paths = new Set();
403 this.clientScripts.set(client, paths);
404 }
405 if (!paths.has(pathname)) {
406 paths.add(pathname);
407 const scripts = await this.loadScripts(
408 pathname,
409 cache ? cache : new Map()
410 );
411 scripts.forEach(command => {
412 // Only define the command if not already defined
413 if (!client[command.name]) {
414 client.defineCommand(command.name, command.options);
415 }
416 });
417 }
418 }
419
420 /**
421 * Clears the command cache

Callers

nothing calls this directly

Calls 2

loadScriptsMethod · 0.95
addMethod · 0.80

Tested by

no test coverage detected