@@ -75,7 +75,7 @@ export class CliService {
7575 }
7676 ] ;
7777
78- return createTasksRunner ( tasks , ctx ) ;
78+ return createTasksRunner ( tasks , this . mapContext ( cmdName , ctx ) ) ;
7979 }
8080
8181 /**
@@ -113,15 +113,16 @@ export class CliService {
113113 const provider = this . commands . get ( cmdName ) ;
114114 const instance = this . injector . get < ICommand > ( provider . useClass ) ! ;
115115
116- if ( instance . $mapContext ) {
117- ctx = instance . $mapContext ( ctx ) ;
118- }
116+ ctx = this . mapContext ( cmdName , ctx ) ;
119117
120118 if ( instance . $beforeExec ) {
121119 await instance . $beforeExec ( ctx ) ;
122120 }
123121
124- return [ ...( await instance . $exec ( ctx ) ) , ...( await this . hooks . emit ( CommandStoreKeys . EXEC_HOOKS , cmdName , ctx ) ) ] ;
122+ return [
123+ ...( await instance . $exec ( ctx ) ) ,
124+ ...( await this . hooks . emit ( CommandStoreKeys . EXEC_HOOKS , cmdName , ctx ) )
125+ ] ;
125126 }
126127
127128 /**
@@ -171,6 +172,17 @@ export class CliService {
171172 } ) ;
172173 }
173174
175+ private mapContext ( cmdName : string , ctx : any ) {
176+ const provider = this . commands . get ( cmdName ) ;
177+ const instance = this . injector . get < ICommand > ( provider . useClass ) ! ;
178+
179+ if ( instance . $mapContext ) {
180+ ctx = instance . $mapContext ( JSON . parse ( JSON . stringify ( ctx ) ) ) ;
181+ }
182+
183+ return ctx ;
184+ }
185+
174186 /**
175187 * Build command and sub-commands
176188 * @param provider
0 commit comments