Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /var/www/html/wincloud_gateway/node_modules/bull/lib/commands/ drwxr-xr-x | |
| Viewing file: Select action/file-type: /**
* 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
*
*/
'use strict';
const fs = require('fs');
const path = require('path');
const promisify = require('util.promisify'); //TODO in node >= 8 could be removed
const utils = require('../utils');
//TODO node >= 10 could be used require('fs').promises()
const _fs = {
readdirAsync: promisify(fs.readdir),
readFileAsync: promisify(fs.readFile)
};
module.exports = (function() {
let scripts;
return async function(client) {
await utils.isRedisReady(client);
scripts = await (scripts || loadScripts(__dirname));
return scripts.map(command => {
return client.defineCommand(command.name, command.options);
});
};
})();
function loadScripts(dir) {
return _fs
.readdirAsync(dir)
.then(files => {
return files.filter(file => {
return path.extname(file) === '.lua';
});
})
.then(files => {
return Promise.all(
files.map(file => {
const longName = path.basename(file, '.lua');
const name = longName.split('-')[0];
const numberOfKeys = parseInt(longName.split('-')[1]);
return _fs.readFileAsync(path.join(dir, file)).then(lua => {
return {
name: name,
options: { numberOfKeys: numberOfKeys, lua: lua.toString() }
};
});
})
);
});
}
|
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.1222 ]-- |