From 2f97923ff13e0c6d2314a9d1c8095891a9296dd7 Mon Sep 17 00:00:00 2001 From: advaiyalad Date: Sat, 20 Feb 2021 22:03:27 -0600 Subject: [PATCH] fix(validation): load process only when defined during validation logging (#50) --- src/lib/validateAndCoerceTypes.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/lib/validateAndCoerceTypes.ts b/src/lib/validateAndCoerceTypes.ts index e45bae01..92a8cb6b 100644 --- a/src/lib/validateAndCoerceTypes.ts +++ b/src/lib/validateAndCoerceTypes.ts @@ -148,9 +148,10 @@ ajv.addKeyword({ ajv.addSchema(schema); /* istanbul ignore next */ -const logObj = process?.stdout?.isTTY - ? (obj: any) => console.dir(obj, { depth: 4, colors: true }) - : (obj: any) => console.log(JSON.stringify(obj, null, 2)); +const logObj = + typeof process !== "undefined" && process?.stdout?.isTTY + ? (obj: any) => console.dir(obj, { depth: 4, colors: true }) + : (obj: any) => console.log(JSON.stringify(obj, null, 2)); export function resolvePath(obj: any, dataPath: string) { const path = dataPath.split("/");