Skip to content

Commit f172e4a

Browse files
committedJun 5, 2024·
fix: enforce DOTENV_KEY and cwd from process
1 parent 6a75888 commit f172e4a

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed
 

‎src/index.ts

+8-7
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,17 @@ const dotenvRun = env({
4242
files: argv.files,
4343
dotenv: {
4444
override: argv.override,
45-
DOTENV_KEY: argv.dotenv_key,
45+
DOTENV_KEY: argv.dotenv_key ?? process.env['DOTENV_KEY'],
4646
},
4747
});
4848

49-
const exportStatements = Object.entries(dotenvRun.raw)
50-
.map(([key, value]) => {
51-
value = JSON.stringify(value).replaceAll(/\r\n|\r|\n/g, '\n');
49+
const exportStatements =
50+
Object.entries(dotenvRun.raw)
51+
.map(([key, value]) => {
52+
value = JSON.stringify(value).replaceAll(/\r\n|\r|\n/g, '\n');
5253

53-
return `export ${key}=${value}`;
54-
})
55-
.join('\n');
54+
return `export ${key}=${value}`;
55+
})
56+
.join('\n') + '\n';
5657

5758
process.stdout.write(exportStatements);

0 commit comments

Comments
 (0)
Please sign in to comment.