-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
111 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Account, EnvRegExp } from '../project'; | ||
|
||
export function findAccountTypeByEnvironment(obj: Record<string, Account>, predicate: string): string | undefined { | ||
for (const key in obj) { | ||
if (obj.hasOwnProperty(key)) { | ||
const list = obj[key].environments?.filter((environment) => new EnvRegExp(environment).test(predicate)); | ||
if (Array.isArray(list) && list.length > 0) { | ||
return key; | ||
} | ||
} | ||
} | ||
return undefined; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
|
||
export function get(obj: Record<string, any> | undefined, path: string, defValue?: any): any { | ||
// If path is not defined or it has false value | ||
if (!path) return undefined; | ||
// Check if path is string or array. Regex : ensure that we do not have '.' and brackets. | ||
// Regex explained: https://regexr.com/58j0k | ||
const pathArray = path.match(/([^[.\]])+/g); | ||
// Find value | ||
const result = pathArray?.reduce((prevObj, key) => { | ||
return prevObj && prevObj[key]; | ||
}, obj); | ||
// If found value is undefined return default value; otherwise return the value | ||
return result === undefined ? defValue : result; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
import { values } from 'lodash'; | ||
|
||
|
||
export function isSet(value?: string | undefined): boolean { | ||
return (typeof value === 'string' && values.length > 0); | ||
} | ||
export function isNonEmptyString(value?: unknown): value is string { | ||
return (typeof value === 'string' && value.length > 0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters