Skip to content
This repository has been archived by the owner on Nov 13, 2023. It is now read-only.

Commit

Permalink
Make suggested changes
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew W. Harn <andrew.harn@broadcom.com>
  • Loading branch information
awharn committed Feb 24, 2023
1 parent 0c3511d commit 107ff54
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions packages/utilities/src/EnvFileUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class EnvFileUtils {
* @returns {void}
* @throws {ImperativeError}
*/
public static setEnvironmentForApp(appName: string, checkCliHomeVariableFirst: boolean = false, envPrefix?: string) {
public static setEnvironmentForApp(appName: string, checkCliHomeVariableFirst = false, envPrefix?: string): void {
const expectedFileLocation = this.getEnvironmentFilePath(appName, checkCliHomeVariableFirst, envPrefix);
if (expectedFileLocation) {
try {
Expand All @@ -60,9 +60,9 @@ export class EnvFileUtils {
* @param {string} appName - The application name
* @param {boolean} checkCliHomeVariableFirst - Check inside of *_CLI_HOME first if it is defined
* @param {string} envPrefix - environment variable prefix
* @returns {string|undefined} - Returns the path if it exists, or undefined if it does not
* @returns {string} - Returns the path string if it exists, or null if it does not
*/
public static getEnvironmentFilePath(appName: string, checkCliHomeVariableFirst: boolean = false, envPrefix?: string): string | undefined {
public static getEnvironmentFilePath(appName: string, checkCliHomeVariableFirst = false, envPrefix?: string): string {
if (checkCliHomeVariableFirst) {
const cliHome = this.getCliHomeEnvironmentFilePath(appName, envPrefix);
if (cliHome) {
Expand All @@ -75,24 +75,24 @@ export class EnvFileUtils {
/**
* Get the expected path for the user's environment variable file
* @param {string} appName - The application name
* @returns {string|undefined} - Returns the path if it exists, or undefined if it does not
* @returns {string} - Returns the path string if it exists, or null if it does not
*/
public static getUserHomeEnvironmentFilePath(appName: string): string | undefined {
public static getUserHomeEnvironmentFilePath(appName: string): string {
const expectedBasename = "." + appName + ".env.json";
const path = join(homedir(), expectedBasename);
if (existsSync(path)) {
return path;
}
return undefined;
return null;
}

/**
* Get the expected path for the user's environment variable file
* @param {string} appName - The application name
* @param {string} envPrefix - The environment variable prefix
* @returns {string|undefined} - Returns the path if it exists, or undefined if it does not
* @returns {string} - Returns the path string if it exists, or null if it does not
*/
public static getCliHomeEnvironmentFilePath(appName: string, envPrefix?: string): string | undefined {
public static getCliHomeEnvironmentFilePath(appName: string, envPrefix?: string): string {
const environmentVariable = (envPrefix ? envPrefix : appName.toUpperCase()) + EnvironmentalVariableSettings.CLI_HOME_SUFFIX;
const expectedBasename = "." + appName + ".env.json";
const expectedDirectory = process.env[environmentVariable];
Expand All @@ -102,6 +102,6 @@ export class EnvFileUtils {
return path;
}
}
return undefined;
return null;
}
}

0 comments on commit 107ff54

Please sign in to comment.