File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Open diff view settings
Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Open diff view settings
Original file line number Diff line number Diff 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 }
Original file line number Diff line number Diff line change 22
33const common = require ( '../common' ) ;
44const assert = require ( 'node:assert' ) ;
5+ const path = require ( 'node:path' ) ;
56const { describe, it } = require ( 'node:test' ) ;
67
78const 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)
You can’t perform that action at this time.
0 commit comments