@@ -148,8 +148,9 @@ export async function getApp(
148148export interface ConfigContext {
149149 org : undefined | string ;
150150 app : undefined | string ;
151- save : ( ) => Promise < void > ;
152- set noSave ( arg : boolean ) ;
151+ configSaved : boolean ;
152+ save ( ) : Promise < void > ;
153+ noSave ( ) : void ;
153154}
154155
155156export function actionHandler <
@@ -171,31 +172,32 @@ export function actionHandler<
171172 rootPath ?.( ...args ) ?? Deno . cwd ( ) ,
172173 context . config ,
173174 ) ;
174- const configContext = getAppFromConfig ( config ) ;
175-
176- let configSaved = false ;
177- const saveConfig = ( ) => {
178- if ( configSaved ) return Promise . resolve ( ) ;
179- configSaved = true ;
180-
181- // TODO: we dont always want to write the config. ie when we write only org but an app exists, or writing org for sandboxes
182- return writeConfig ( config , configContext ) ;
175+ const configContext : ConfigContext = {
176+ ...getAppFromConfig ( config ) ,
177+ configSaved : false ,
178+ save ( ) {
179+ if ( this . configSaved ) return Promise . resolve ( ) ;
180+ this . configSaved = true ;
181+
182+ // TODO: we dont always want to write the config. ie when we write only org but an app exists, or writing org for sandboxes
183+ return writeConfig ( config , {
184+ org : this . org ,
185+ app : this . app ,
186+ } ) ;
187+ } ,
188+ noSave ( ) {
189+ this . configSaved = true ;
190+ } ,
183191 } ;
184192
185193 await cb . call (
186194 this ,
187- {
188- ...configContext ,
189- save : saveConfig ,
190- set noSave ( arg : boolean ) {
191- configSaved = arg ;
192- } ,
193- } as unknown as ConfigContext ,
195+ configContext ,
194196 context ,
195197 ...args ,
196198 ) ;
197199
198- await saveConfig ( ) ;
200+ await configContext . save ( ) ;
199201 } catch ( e ) {
200202 if ( e instanceof ValidationError ) {
201203 throw e ;
0 commit comments