@@ -8,7 +8,6 @@ import { FileSystem } from '@rushstack/node-core-library';
88import type { IPhasedCommandPlugin , PhasedCommandHooks } from '../../pluginFramework/PhasedCommandHooks' ;
99import type { IEnvironment } from '../../utilities/Utilities' ;
1010import type { Operation } from './Operation' ;
11- import type { IOperationRunnerContext } from './IOperationRunner' ;
1211import type { IOperationExecutionResult } from './IOperationExecutionResult' ;
1312
1413const PLUGIN_NAME : 'NodeDiagnosticDirPlugin' = 'NodeDiagnosticDirPlugin' ;
@@ -44,32 +43,25 @@ export class NodeDiagnosticDirPlugin implements IPhasedCommandPlugin {
4443 return diagnosticDir ;
4544 } ;
4645
47- hooks . beforeExecuteOperation . tap (
46+ hooks . createEnvironmentForOperation . tap (
4847 PLUGIN_NAME ,
49- ( operation : IOperationRunnerContext & IOperationExecutionResult ) : undefined => {
50- const diagnosticDir : string | undefined = getDiagnosticDir ( operation . operation ) ;
48+ ( env : IEnvironment , record : IOperationExecutionResult ) => {
49+ const diagnosticDir : string | undefined = getDiagnosticDir ( record . operation ) ;
5150 if ( ! diagnosticDir ) {
52- return ;
51+ return env ;
5352 }
5453
5554 // Not all versions of NodeJS create the directory, so ensure it exists:
5655 FileSystem . ensureFolder ( diagnosticDir ) ;
57- }
58- ) ;
59-
60- hooks . createEnvironmentForOperation . tap ( PLUGIN_NAME , ( env : IEnvironment , operation : Operation ) => {
61- const diagnosticDir : string | undefined = getDiagnosticDir ( operation ) ;
62- if ( ! diagnosticDir ) {
63- return env ;
64- }
6556
66- const { NODE_OPTIONS } = env ;
57+ const { NODE_OPTIONS } = env ;
6758
68- const diagnosticDirEnv : string = `--diagnostic-dir="${ diagnosticDir } "` ;
59+ const diagnosticDirEnv : string = `--diagnostic-dir="${ diagnosticDir } "` ;
6960
70- env . NODE_OPTIONS = NODE_OPTIONS ? `${ NODE_OPTIONS } ${ diagnosticDirEnv } ` : diagnosticDirEnv ;
61+ env . NODE_OPTIONS = NODE_OPTIONS ? `${ NODE_OPTIONS } ${ diagnosticDirEnv } ` : diagnosticDirEnv ;
7162
72- return env ;
73- } ) ;
63+ return env ;
64+ }
65+ ) ;
7466 }
7567}
0 commit comments