@@ -854,28 +854,6 @@ static ExitCode InitializeNodeWithArgsInternal(
854
854
HandleEnvOptions (per_process::cli_options->per_isolate ->per_env );
855
855
856
856
std::string node_options;
857
- auto file_paths = node::Dotenv::GetPathFromArgs (*argv);
858
-
859
- if (!file_paths.empty ()) {
860
- CHECK (!per_process::v8_initialized);
861
-
862
- for (const auto & file_path : file_paths) {
863
- switch (per_process::dotenv_file.ParsePath (file_path)) {
864
- case Dotenv::ParseResult::Valid:
865
- break ;
866
- case Dotenv::ParseResult::InvalidContent:
867
- errors->push_back (file_path + " : invalid format" );
868
- break ;
869
- case Dotenv::ParseResult::FileError:
870
- errors->push_back (file_path + " : not found" );
871
- break ;
872
- default :
873
- UNREACHABLE ();
874
- }
875
- }
876
-
877
- per_process::dotenv_file.AssignNodeOptionsIfAvailable (&node_options);
878
- }
879
857
880
858
#if !defined(NODE_WITHOUT_NODE_OPTIONS)
881
859
if (!(flags & ProcessInitializationFlags::kDisableNodeOptionsEnv )) {
@@ -912,6 +890,34 @@ static ExitCode InitializeNodeWithArgsInternal(
912
890
if (exit_code != ExitCode::kNoFailure ) return exit_code;
913
891
}
914
892
893
+ if (!per_process::cli_options->per_isolate ->per_env ->env_file .empty ()) {
894
+ CHECK (!per_process::v8_initialized);
895
+
896
+ for (const auto & file_path :
897
+ per_process::cli_options->per_isolate ->per_env ->env_file ) {
898
+ switch (per_process::dotenv_file.ParsePath (file_path)) {
899
+ case Dotenv::ParseResult::Valid:
900
+ break ;
901
+ case Dotenv::ParseResult::InvalidContent:
902
+ errors->push_back (file_path + " : invalid format" );
903
+ break ;
904
+ case Dotenv::ParseResult::FileError:
905
+ errors->push_back (file_path + " : not found" );
906
+ break ;
907
+ default :
908
+ UNREACHABLE ();
909
+ }
910
+ }
911
+
912
+ std::vector<std::string> env_argv = ParseNodeOptionsEnvVar (
913
+ per_process::dotenv_file.GetNodeOptions (), errors);
914
+ env_argv.insert (env_argv.begin (), argv->at (0 ));
915
+
916
+ const ExitCode exit_code =
917
+ ProcessGlobalArgsInternal (&env_argv, nullptr , errors, kAllowedInEnvvar );
918
+ if (exit_code != ExitCode::kNoFailure ) return exit_code;
919
+ }
920
+
915
921
// Set the process.title immediately after processing argv if --title is set.
916
922
if (!per_process::cli_options->title .empty ())
917
923
uv_set_process_title (per_process::cli_options->title .c_str ());
0 commit comments