@@ -25,6 +25,7 @@ import { Event } from '../api/EventHooks';
2525import { EnvironmentVariableNames } from '../api/EnvironmentConfiguration' ;
2626import { RushConstants } from '../logic/RushConstants' ;
2727import { PnpmSyncUtilities } from '../utilities/PnpmSyncUtilities' ;
28+ import { initializeDotEnv } from '../logic/dotenv' ;
2829
2930interface IRushXCommandLineArguments {
3031 /**
@@ -77,18 +78,31 @@ export class RushXCommandLine {
7778 public static async launchRushXAsync ( launcherVersion : string , options : ILaunchOptions ) : Promise < void > {
7879 try {
7980 const rushxArguments : IRushXCommandLineArguments = RushXCommandLine . _parseCommandLineArguments ( ) ;
80- const rushConfiguration : RushConfiguration | undefined = RushConfiguration . tryLoadFromDefaultLocation ( {
81+ const rushJsonFilePath : string | undefined = RushConfiguration . tryFindRushJsonLocation ( {
8182 showVerbose : false
8283 } ) ;
84+ const { isDebug, help, ignoreHooks } = rushxArguments ;
85+
86+ const terminalProvider : ITerminalProvider = new ConsoleTerminalProvider ( {
87+ debugEnabled : isDebug ,
88+ verboseEnabled : isDebug
89+ } ) ;
90+ const terminal : ITerminal = new Terminal ( terminalProvider ) ;
91+
92+ initializeDotEnv ( terminal , rushJsonFilePath ) ;
93+
94+ const rushConfiguration : RushConfiguration | undefined = rushJsonFilePath
95+ ? RushConfiguration . loadFromConfigurationFile ( rushJsonFilePath )
96+ : undefined ;
8397 const eventHooksManager : EventHooksManager | undefined = rushConfiguration
8498 ? new EventHooksManager ( rushConfiguration )
8599 : undefined ;
86100
87101 const suppressHooks : boolean = process . env [ EnvironmentVariableNames . _RUSH_RECURSIVE_RUSHX_CALL ] === '1' ;
88- const attemptHooks : boolean = ! suppressHooks && ! rushxArguments . help ;
102+ const attemptHooks : boolean = ! suppressHooks && ! help ;
89103 if ( attemptHooks ) {
90104 try {
91- eventHooksManager ?. handle ( Event . preRushx , rushxArguments . isDebug , rushxArguments . ignoreHooks ) ;
105+ eventHooksManager ?. handle ( Event . preRushx , isDebug , ignoreHooks ) ;
92106 } catch ( error ) {
93107 // eslint-disable-next-line no-console
94108 console . error ( Colorize . red ( 'PreRushx hook error: ' + ( error as Error ) . message ) ) ;
@@ -98,10 +112,10 @@ export class RushXCommandLine {
98112 // promise exception), so we start with the assumption that the exit code is 1
99113 // and set it to 0 only on success.
100114 process . exitCode = 1 ;
101- await RushXCommandLine . _launchRushXInternalAsync ( rushxArguments , rushConfiguration , options ) ;
115+ await RushXCommandLine . _launchRushXInternalAsync ( terminal , rushxArguments , rushConfiguration , options ) ;
102116 if ( attemptHooks ) {
103117 try {
104- eventHooksManager ?. handle ( Event . postRushx , rushxArguments . isDebug , rushxArguments . ignoreHooks ) ;
118+ eventHooksManager ?. handle ( Event . postRushx , isDebug , ignoreHooks ) ;
105119 } catch ( error ) {
106120 // eslint-disable-next-line no-console
107121 console . error ( Colorize . red ( 'PostRushx hook error: ' + ( error as Error ) . message ) ) ;
@@ -122,6 +136,7 @@ export class RushXCommandLine {
122136 }
123137
124138 private static async _launchRushXInternalAsync (
139+ terminal : ITerminal ,
125140 rushxArguments : IRushXCommandLineArguments ,
126141 rushConfiguration : RushConfiguration | undefined ,
127142 options : ILaunchOptions
@@ -218,12 +233,6 @@ export class RushXCommandLine {
218233 }
219234 } ) ;
220235
221- const terminalProvider : ITerminalProvider = new ConsoleTerminalProvider ( {
222- debugEnabled : rushxArguments . isDebug ,
223- verboseEnabled : rushxArguments . isDebug
224- } ) ;
225- const terminal : ITerminal = new Terminal ( terminalProvider ) ;
226-
227236 if ( rushConfiguration ?. isPnpm && rushConfiguration ?. experimentsConfiguration ) {
228237 const { configuration : experiments } = rushConfiguration ?. experimentsConfiguration ;
229238
0 commit comments