Skip to content

Commit

Permalink
fix: enforce DOTENV_KEY and cwd from process
Browse files Browse the repository at this point in the history
  • Loading branch information
KernelPanic92 committed Jun 5, 2024
1 parent 6a75888 commit f172e4a
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

0 comments on commit f172e4a

Please sign in to comment.