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

Commit

Permalink
feat(): all arguments passed should be compared as case insensitive
Browse files Browse the repository at this point in the history
  • Loading branch information
jthoms1 committed Dec 12, 2016
1 parent af036ec commit 085c897
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
43 changes: 42 additions & 1 deletion src/spec/config.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BuildContext } from '../util/interfaces';
import { bundlerStrategy, generateContext, getConfigValue, getUserConfigFile, replacePathVars } from '../util/config';
import { bundlerStrategy, generateContext, getConfigValue, getUserConfigFile, replacePathVars, hasArg } from '../util/config';
import { addArgv, setAppPackageJsonData, setProcessEnvVar, setProcessArgs, setProcessEnv, setCwd } from '../util/config';
import { resolve } from 'path';

Expand Down Expand Up @@ -287,6 +287,47 @@ describe('config', () => {

});

describe('hasArg function', () => {
it('should return false when a match is not found', () => {
const result = hasArg('--full', '-f');
expect(result).toBeFalsy();
});

it('should match on a fullname arg', () => {
addArgv('--full');

const result = hasArg('--full');
expect(result).toBeTruthy();
});

it('should match on a shortname arg', () => {
addArgv('-f');

const result = hasArg('--full', '-f');
expect(result).toBeTruthy();
});

it('should compare fullnames as case insensitive', () => {
addArgv('--full');
addArgv('--TEST');

const result = hasArg('--Full');
const result2 = hasArg('--test');
expect(result).toBeTruthy();
expect(result2).toBeTruthy();
});

it('should compare shortnames as case insensitive', () => {
addArgv('-f');
addArgv('-T');

const result = hasArg('-F');
const result2 = hasArg('-t');
expect(result).toBeTruthy();
expect(result2).toBeTruthy();
})
});

let context: BuildContext;
beforeEach(() => {
setProcessArgs(['node', 'ionic-app-scripts']);
Expand Down
3 changes: 2 additions & 1 deletion src/util/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,8 @@ export function hasConfigValue(context: BuildContext, argFullName: string, argSh


export function hasArg(fullName: string, shortName: string = null): boolean {
return !!(processArgv.some(a => a === fullName) || (shortName !== null && processArgv.some(a => a === shortName)));
return !!(processArgv.some(a => a.toLowerCase() === fullName.toLowerCase()) ||
(shortName !== null && processArgv.some(a => a.toLowerCase() === shortName.toLowerCase())));
}


Expand Down

0 comments on commit 085c897

Please sign in to comment.