@@ -14,6 +14,7 @@ module.exports = {
14
14
let { cwd, preferences } = inv . _project
15
15
let jsonMocks = join ( cwd , 'sandbox-invoke-mocks.json' )
16
16
let jsMocks = join ( cwd , 'sandbox-invoke-mocks.js' )
17
+ let inputPromptOpen = false
17
18
18
19
let pragmas = [ 'events' , 'queues' , 'scheduled' , 'tables-streams' ]
19
20
let prefs = preferences ?. sandbox ?. invoker
@@ -45,7 +46,7 @@ module.exports = {
45
46
strong : colors . white ,
46
47
}
47
48
}
48
- if ( input === 'i' ) {
49
+ if ( input === 'i' && ! inputPromptOpen ) {
49
50
if ( Object . keys ( events ) . length === 1 ) {
50
51
let none = 'No Lambdas found to invoke'
51
52
if ( pragmas . length ) update . status ( none , `Using the following pragmas: @${ pragmas . join ( ', @' ) } ` )
@@ -91,6 +92,21 @@ module.exports = {
91
92
} , options )
92
93
mockName = selection . mock
93
94
userPayload = mocks [ pragma ] [ name ] [ mockName ] || { }
95
+
96
+ if ( typeof userPayload === "function" ) {
97
+ inputPromptOpen = true ;
98
+ let { mockinput } = await prompt (
99
+ {
100
+ type : "input" ,
101
+ name : "mockinput" ,
102
+ message : "What input to use for mock function?" ,
103
+ } ,
104
+ options
105
+ ) ;
106
+ inputPromptOpen = false ;
107
+ let mockInputArgs = mockinput . split ( "," ) ;
108
+ userPayload = userPayload ( ...mockInputArgs ) ;
109
+ }
94
110
}
95
111
96
112
let payload
0 commit comments