n8n/packages/@n8n/benchmark/scripts/utils/flags.mjs
Tomi Turtiainen b9d157db40
fix(benchmark): Fix args formatting & validate scaling mode env vars (#10766)
Co-authored-by: Cornelius Suermann <cornelius@n8n.io>
2024-09-11 11:12:03 +03:00

21 lines
464 B
JavaScript

// @ts-check
/**
* Converts an object of flags to an array of CLI arguments.
*
* @param {Record<string, string | undefined>} flags
*
* @returns {string[]}
*/
export function flagsObjectToCliArgs(flags) {
return Object.entries(flags)
.filter(([, value]) => value !== undefined)
.map(([key, value]) => {
if (typeof value === 'string' && value.includes(' ')) {
return `--${key}="${value}"`;
} else {
return `--${key}=${value}`;
}
});
}