From 6c35ba24c6c4dfd7139a64bf383965fe2ccc869f Mon Sep 17 00:00:00 2001 From: Amit Dhamu Date: Wed, 4 May 2022 11:24:35 +0100 Subject: [PATCH] Trim keys --- package.json | 2 +- src/__tests__/index.test.ts | 10 +++++----- src/index.ts | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index d6dfd2c..1d4dabb 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/__tests__/index.test.ts b/src/__tests__/index.test.ts index 8bb901a..fab40cb 100644 --- a/src/__tests__/index.test.ts +++ b/src/__tests__/index.test.ts @@ -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({ diff --git a/src/index.ts b/src/index.ts index 1b03df2..62e3c41 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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())