diff --git a/src/commands/hardis/lint/access.ts b/src/commands/hardis/lint/access.ts index fe1597724..4d440403b 100644 --- a/src/commands/hardis/lint/access.ts +++ b/src/commands/hardis/lint/access.ts @@ -121,7 +121,7 @@ export default class Access extends SfdxCommand { public async run(): Promise { const config = await getConfig("user"); this.folder = this.flags.folder || "./force-app"; - this.hasToDisplayJsonOnly = process.argv.includes("--json"); + this.hasToDisplayJsonOnly = this.argv.includes("--json"); this.ignoreSourceElementsIfDefined(); this.ignoreRightElementsIfDefined(config); diff --git a/src/common/utils/index.ts b/src/common/utils/index.ts index d55ced61e..fa48e671b 100644 --- a/src/common/utils/index.ts +++ b/src/common/utils/index.ts @@ -546,7 +546,7 @@ export async function execCommand( // Call command (disable color before for json parsing) const prevForceColor = process.env.FORCE_COLOR; process.env.FORCE_COLOR = "0"; - const output = options.output !== null ? options.output : !process.argv.includes("--json"); + const output = options.output !== null ? options.output : !(process?.argv ||[]).includes("--json"); let spinner: any; if (output && !(options.spinner === false)) { spinner = ora({ text: commandLog, spinner: "moon" }).start(); @@ -897,7 +897,7 @@ export function uxLog(commandThis: any, text: string) { text = text.includes("[sfdx-hardis]") ? text : "[sfdx-hardis]" + (text.startsWith("[") ? "" : " ") + text; if (commandThis?.ux) { commandThis.ux.log(text); - } else if (!process.argv.includes("--json")) { + } else if (!(process?.argv ||[]).includes("--json")) { console.log(text); } if (globalThis.hardisLogFileStream) { diff --git a/src/hooks/init/check-local-sfdx-hardis-files.ts b/src/hooks/init/check-local-sfdx-hardis-files.ts index 979a34e8b..3b7db38a9 100644 --- a/src/hooks/init/check-local-sfdx-hardis-files.ts +++ b/src/hooks/init/check-local-sfdx-hardis-files.ts @@ -8,7 +8,7 @@ export const hook = async (options: any) => { // Skip hooks from other commands than hardis:scratch commands const commandId = options?.id || ""; - if (!process.argv.includes("--json")) { + if (!process?.argv?.includes("--json")) { await manageGitIgnoreForceIgnore(commandId); } }; diff --git a/src/hooks/init/log.ts b/src/hooks/init/log.ts index 1de66f807..6e102d87d 100644 --- a/src/hooks/init/log.ts +++ b/src/hooks/init/log.ts @@ -22,6 +22,6 @@ export const hook = async (options: any) => { const logFileName = (new Date().toJSON().slice(0, 19) + "-" + commandId + ".log").replace(/:/g, "-"); const hardisLogFile = path.resolve(path.join(commandsLogFolder, logFileName)); globalThis.hardisLogFileStream = fs.createWriteStream(hardisLogFile, { flags: "a" }); - globalThis.hardisLogFileStream.write(process.argv.join(" ")); + globalThis.hardisLogFileStream.write((process?.argv || []).join(" ")); } }; diff --git a/src/hooks/prerun/auth.ts b/src/hooks/prerun/auth.ts index a7cf3aa6f..e1735a677 100644 --- a/src/hooks/prerun/auth.ts +++ b/src/hooks/prerun/auth.ts @@ -54,7 +54,7 @@ export const hook = async (options: any) => { } // Manage authentication if org is required but current user is disconnected if ( - ((options?.Command?.requiresUsername === true && !process.argv.includes("--skipauth")) || options.checkAuth === true) && + ((options?.Command?.requiresUsername === true && !(process?.argv ||[]).includes("--skipauth")) || options.checkAuth === true) && !(options.devHub === true) ) { const orgAlias = options.alias @@ -87,7 +87,7 @@ async function authOrg(orgAlias: string, options: any) { orgDisplayCommand += " --targetusername " + orgAlias; setDefaultUsername = true; } else { - if (process.argv.includes("-u") || process.argv.includes("--targetusername")) { + if ((process?.argv ||[]).includes("-u") || (process?.argv ||[]).includes("--targetusername")) { const posUsername = process.argv.indexOf("-u") > -1 ? process.argv.indexOf("-u") + 1 : process.argv.indexOf("--targetusername") + 1; orgDisplayCommand += " --targetusername " + process.argv[posUsername]; }