mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-15 09:04:07 -08:00
b9d157db40
Co-authored-by: Cornelius Suermann <cornelius@n8n.io>
21 lines
464 B
JavaScript
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}`;
|
|
}
|
|
});
|
|
}
|