From 5a01ee6cec025e9187285dd66f91afa11f7f2447 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Fri, 7 Jul 2023 09:52:03 -0400 Subject: [PATCH] refactor: rewrite arg parsing --- src/index.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/index.ts b/src/index.ts index cb3e600..24f5d4e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -445,10 +445,17 @@ export class Config { } public parseArg(args: arg.Result) { + const argPairs = args._.reduce((prev: any, item: any) => { + const parts = item.split("="); + const key = parts[0].replace("-", ""); + prev[key] = parts[1]; + + return prev; + }, {}); + // eslint-disable-next-line @typescript-eslint/no-for-in-array - for (let key in args._) { - let newKey = key.replace("-", ""); - objectPath.set(this.data, newKey, args[key]); + for (const key of argPairs) { + objectPath.set(this.data, key, argPairs[key]); } }