Skip to content

Commit

Permalink
Trim keys
Browse files Browse the repository at this point in the history
  • Loading branch information
Amit Dhamu committed May 4, 2022
1 parent f25669a commit 6c35ba2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "arge",
"version": "1.1.2",
"version": "1.1.3",
"description": "A simple utility to parse command line arguments and flags",
"keywords": [
"argv",
Expand Down
10 changes: 5 additions & 5 deletions src/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ describe('arge', () => {
it('trims spaces between keys and values', () => {
const argv = [
...baseArgs,
'-f ',
'--dry-run ',
'--mode = development',
'--test = false',
'--retries = 100',
' -f ',
' --dry-run ',
' --mode = development',
' --test = false',
' --retries = 100',
]

expect(arge(argv)).toEqual({
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const arge = (
: args
).reduce((acc, curr) => {
const [k, v = 'true'] = curr.split('=')
let key = k.replace(/^-+/, '')
let key = k.trim().replace(/^-+/, '')

key = options.camelCaseKeys
? key.replace(/-([a-z])/g, g => g[1].toUpperCase())
Expand Down

0 comments on commit 6c35ba2

Please sign in to comment.