Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 119e045

Browse filesBrowse files
tniessentargos
authored andcommitted
src: do not coerce dotenv paths
PR-URL: #51425 Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
1 parent 7420a7d commit 119e045
Copy full SHA for 119e045

File tree

Expand file treeCollapse file tree

2 files changed

+14
-3
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+14
-3
lines changed
Open diff view settings
Collapse file

‎src/node.cc‎

Copy file name to clipboardExpand all lines: src/node.cc
+1-3Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -865,11 +865,9 @@ static ExitCode InitializeNodeWithArgsInternal(
865865

866866
if (!file_paths.empty()) {
867867
CHECK(!per_process::v8_initialized);
868-
auto cwd = Environment::GetCwd(Environment::GetExecPath(*argv));
869868

870869
for (const auto& file_path : file_paths) {
871-
std::string path = cwd + kPathSeparator + file_path;
872-
auto path_exists = per_process::dotenv_file.ParsePath(path);
870+
bool path_exists = per_process::dotenv_file.ParsePath(file_path);
873871

874872
if (!path_exists) errors->push_back(file_path + ": not found");
875873
}
Collapse file

‎test/parallel/test-dotenv-edge-cases.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-dotenv-edge-cases.js
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
const common = require('../common');
44
const assert = require('node:assert');
5+
const path = require('node:path');
56
const { describe, it } = require('node:test');
67

78
const validEnvFilePath = '../fixtures/dotenv/valid.env';
@@ -25,6 +26,18 @@ describe('.env supports edge cases', () => {
2526
assert.strictEqual(child.code, 0);
2627
});
2728

29+
it('supports absolute paths', async () => {
30+
const code = `
31+
require('assert').strictEqual(process.env.BASIC, 'basic');
32+
`.trim();
33+
const child = await common.spawnPromisified(
34+
process.execPath,
35+
[ `--env-file=${path.resolve(__dirname, validEnvFilePath)}`, '--eval', code ],
36+
);
37+
assert.strictEqual(child.stderr, '');
38+
assert.strictEqual(child.code, 0);
39+
});
40+
2841
it('should handle non-existent .env file', async () => {
2942
const code = `
3043
require('assert').strictEqual(1, 1)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.