Skip to content

Commit a5aef1b

Browse files
committed
refactor: add createObjectFromArguments function
1 parent 98ed733 commit a5aef1b

1 file changed

Lines changed: 2 additions & 9 deletions

File tree

src/argv2Object.mjs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
// ━━ IMPORT MODULES ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
2626
// » IMPORT LOCAL MODULES
2727
import { COMMAND_LINE_PATTERNS, ERROR_MESSAGES } from '#constants';
28-
import { formatKey, convertValue } from '#functions';
28+
import { createObjectFromArguments } from '#functions';
2929

3030
// ━━ TYPE DEFINITIONS ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
3131
/**
@@ -82,14 +82,7 @@ const argv2Object = (unixmode = false) => {
8282
throw new Error(message);
8383
}
8484

85-
const entries = [...argumentsv].map(argumentv => {
86-
const [k, v] = argumentv.split('=');
87-
const key = formatKey(k, 'snakecase');
88-
const value = convertValue(v);
89-
return [key, value];
90-
});
91-
92-
return Object.fromEntries(entries);
85+
return createObjectFromArguments(argumentsv, 'snakecase');
9386
};
9487

9588
// ━━ EXPORT MODULE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

0 commit comments

Comments
 (0)