Comparing version 0.0.3 to 0.0.4
@@ -63,12 +63,7 @@ "use strict"; | ||
const envValue = env[key]; | ||
if (schemaOrSpec instanceof z.ZodType) { | ||
try { | ||
try { | ||
if (schemaOrSpec instanceof z.ZodType) { | ||
parsed[key] = (0, preprocessors_1.getSchemaWithPreprocessor)(schemaOrSpec).parse(envValue); | ||
} | ||
catch (e) { | ||
errors.push([key, envValue, e]); | ||
} | ||
} | ||
else if (envValue == null) { | ||
try { | ||
else if (envValue == null) { | ||
const [hasDefault, defaultValue] = resolveDefaultValueForSpec(isProd, isDev, schemaOrSpec); | ||
@@ -86,8 +81,8 @@ if (hasDefault) { | ||
} | ||
catch (e) { | ||
errors.push([key, envValue, e]); | ||
else { | ||
parsed[key] = (0, preprocessors_1.getSchemaWithPreprocessor)(schemaOrSpec.schema).parse(envValue); | ||
} | ||
} | ||
else { | ||
parsed[key] = (0, preprocessors_1.getSchemaWithPreprocessor)(schemaOrSpec.schema).parse(envValue); | ||
catch (e) { | ||
errors.push([key, envValue, e]); | ||
} | ||
@@ -102,4 +97,6 @@ } | ||
.map((line) => ` ${line}`) | ||
.join("\n")}\n (received \`${(0, colorette_1.cyan)(v)}\`)`) | ||
.join("\n\n")}`); | ||
.join("\n")}\n (received ${typeof v === "undefined" ? (0, colorette_1.cyan)("undefined") : `\`${(0, colorette_1.cyan)(v)}\``})${schemas[k]?.description | ||
? `\n\n Description of [${(0, colorette_1.yellow)(k)}]: ${schemas[k].description}` | ||
: ""}`) | ||
.join("\n\n")}\n`); | ||
} | ||
@@ -106,0 +103,0 @@ return [parsed, resolvedNodeEnv]; |
@@ -5,3 +5,4 @@ import { NodeEnvInfo, ParsedSchema, ParseOptions, RestrictSchemas, Schemas } from "./parse-core"; | ||
/** | ||
* Should the environment be augmented by reading in a `.env` file? | ||
* Should the environment be augmented by reading in a `.env` file? (Default: | ||
* `true`) | ||
*/ | ||
@@ -8,0 +9,0 @@ dotenv?: boolean; |
{ | ||
"name": "znv", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "Parse your environment with Zod schemas", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28566
412