mirror of
https://github.com/outline/outline.git
synced 2025-12-30 15:30:12 -06:00
22 lines
574 B
TypeScript
22 lines
574 B
TypeScript
/**
|
|
* Get the value of a command line argument
|
|
*
|
|
* @param name The name of the argument
|
|
* @param shortName The optioanl short name
|
|
* @returns The value of the argument or undefined if the argument is not present
|
|
*/
|
|
export function getArg(name: string, shortName?: string) {
|
|
const argument = process.argv
|
|
.slice(2)
|
|
.filter(
|
|
(arg) =>
|
|
arg.startsWith(`--${name}=`) ||
|
|
(shortName && arg.startsWith(`-${shortName}=`))
|
|
)
|
|
.map((arg) => arg.split("=")[1])
|
|
.map((arg) => arg.trim())
|
|
.join(",");
|
|
|
|
return argument || undefined;
|
|
}
|