Skip to content
This repository was archived by the owner on May 1, 2020. It is now read-only.

Commit 085c897

Browse files
committed
feat(): all arguments passed should be compared as case insensitive
1 parent af036ec commit 085c897

File tree

2 files changed

+44
-2
lines changed

2 files changed

+44
-2
lines changed

src/spec/config.spec.ts

+42-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { BuildContext } from '../util/interfaces';
2-
import { bundlerStrategy, generateContext, getConfigValue, getUserConfigFile, replacePathVars } from '../util/config';
2+
import { bundlerStrategy, generateContext, getConfigValue, getUserConfigFile, replacePathVars, hasArg } from '../util/config';
33
import { addArgv, setAppPackageJsonData, setProcessEnvVar, setProcessArgs, setProcessEnv, setCwd } from '../util/config';
44
import { resolve } from 'path';
55

@@ -287,6 +287,47 @@ describe('config', () => {
287287

288288
});
289289

290+
describe('hasArg function', () => {
291+
it('should return false when a match is not found', () => {
292+
const result = hasArg('--full', '-f');
293+
expect(result).toBeFalsy();
294+
});
295+
296+
it('should match on a fullname arg', () => {
297+
addArgv('--full');
298+
299+
const result = hasArg('--full');
300+
expect(result).toBeTruthy();
301+
});
302+
303+
it('should match on a shortname arg', () => {
304+
addArgv('-f');
305+
306+
const result = hasArg('--full', '-f');
307+
expect(result).toBeTruthy();
308+
});
309+
310+
it('should compare fullnames as case insensitive', () => {
311+
addArgv('--full');
312+
addArgv('--TEST');
313+
314+
const result = hasArg('--Full');
315+
const result2 = hasArg('--test');
316+
expect(result).toBeTruthy();
317+
expect(result2).toBeTruthy();
318+
});
319+
320+
it('should compare shortnames as case insensitive', () => {
321+
addArgv('-f');
322+
addArgv('-T');
323+
324+
const result = hasArg('-F');
325+
const result2 = hasArg('-t');
326+
expect(result).toBeTruthy();
327+
expect(result2).toBeTruthy();
328+
})
329+
});
330+
290331
let context: BuildContext;
291332
beforeEach(() => {
292333
setProcessArgs(['node', 'ionic-app-scripts']);

src/util/config.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,8 @@ export function hasConfigValue(context: BuildContext, argFullName: string, argSh
283283

284284

285285
export function hasArg(fullName: string, shortName: string = null): boolean {
286-
return !!(processArgv.some(a => a === fullName) || (shortName !== null && processArgv.some(a => a === shortName)));
286+
return !!(processArgv.some(a => a.toLowerCase() === fullName.toLowerCase()) ||
287+
(shortName !== null && processArgv.some(a => a.toLowerCase() === shortName.toLowerCase())));
287288
}
288289

289290

0 commit comments

Comments
 (0)