You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-01 16:46:54 +03:00
RESP3 Support - Some commands responses in RESP3 aren't stable yet and therefore return an "untyped" ReplyUnion. Sentinel TypeMapping Correctly types Multi commands Note: some API changes to be further documented in v4-to-v5.md
67 lines
1.6 KiB
JavaScript
67 lines
1.6 KiB
JavaScript
import yargs from 'yargs';
|
|
import { hideBin } from 'yargs/helpers';
|
|
import { promises as fs } from 'node:fs';
|
|
import { fork } from 'node:child_process';
|
|
import { URL, fileURLToPath } from 'node:url';
|
|
import { once } from 'node:events';
|
|
import { extname } from 'node:path';
|
|
|
|
async function getPathChoices() {
|
|
const dirents = await fs.readdir(new URL('.', import.meta.url), {
|
|
withFileTypes: true
|
|
});
|
|
|
|
const choices = [];
|
|
for (const dirent of dirents) {
|
|
if (!dirent.isDirectory()) continue;
|
|
|
|
choices.push(dirent.name);
|
|
}
|
|
|
|
return choices;
|
|
}
|
|
|
|
const argv = hideBin(process.argv);
|
|
|
|
async function getName() {
|
|
return yargs(argv)
|
|
.option('name', {
|
|
demandOption: true,
|
|
choices: await getPathChoices()
|
|
})
|
|
.parseSync().name;
|
|
}
|
|
|
|
const runnerPath = fileURLToPath(new URL('runner.js', import.meta.url)),
|
|
path = new URL(`${await getName()}/`, import.meta.url);
|
|
|
|
async function getMetadata() {
|
|
try {
|
|
return await import(new URL('index.js', path));
|
|
} catch (err) {
|
|
if (err.code === 'ERR_MODULE_NOT_FOUND') return;
|
|
|
|
throw err;
|
|
}
|
|
}
|
|
|
|
const metadata = await getMetadata(),
|
|
timestamp = Date.now();
|
|
|
|
for (const file of await fs.readdir(path)) {
|
|
if (file === 'index.js' || extname(file) !== '.js') continue;
|
|
|
|
const benchmarkProcess = fork(runnerPath, [
|
|
...argv,
|
|
'--path',
|
|
fileURLToPath(path) + file
|
|
]);
|
|
|
|
await once(benchmarkProcess, 'message');
|
|
benchmarkProcess.send({
|
|
metadata,
|
|
timestamp
|
|
});
|
|
await once(benchmarkProcess, 'close');
|
|
}
|