From f172e4a056a07b9066707308e6d56c37b4b3f4f5 Mon Sep 17 00:00:00 2001 From: Iacopo Ciao Date: Wed, 5 Jun 2024 17:27:53 +0200 Subject: [PATCH] fix: enforce DOTENV_KEY and cwd from process --- src/index.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/index.ts b/src/index.ts index f11c394..ee78666 100644 --- a/src/index.ts +++ b/src/index.ts @@ -42,16 +42,17 @@ const dotenvRun = env({ files: argv.files, dotenv: { override: argv.override, - DOTENV_KEY: argv.dotenv_key, + DOTENV_KEY: argv.dotenv_key ?? process.env['DOTENV_KEY'], }, }); -const exportStatements = Object.entries(dotenvRun.raw) - .map(([key, value]) => { - value = JSON.stringify(value).replaceAll(/\r\n|\r|\n/g, '\n'); +const exportStatements = + Object.entries(dotenvRun.raw) + .map(([key, value]) => { + value = JSON.stringify(value).replaceAll(/\r\n|\r|\n/g, '\n'); - return `export ${key}=${value}`; - }) - .join('\n'); + return `export ${key}=${value}`; + }) + .join('\n') + '\n'; process.stdout.write(exportStatements);