@@ -24,7 +24,6 @@ import { ChannelLogger } from '../utilities/vsCodeUtils'
24
24
import { tryGetAbsolutePath } from '../utilities/workspaceUtils'
25
25
import { DefaultValidatingSamCliProcessInvoker } from './cli/defaultValidatingSamCliProcessInvoker'
26
26
import { SamCliBuildInvocation , SamCliBuildInvocationArguments } from './cli/samCliBuild'
27
- import { SamCliProcessInvoker } from './cli/samCliInvokerUtils'
28
27
import { SamCliLocalInvokeInvocation , SamCliLocalInvokeInvocationArguments } from './cli/samCliLocalInvoke'
29
28
import { SamLaunchRequestArgs } from './debugger/samDebugSession'
30
29
@@ -117,53 +116,12 @@ export async function makeInputTemplate(config: SamLaunchRequestArgs): Promise<s
117
116
return pathutil . normalize ( inputTemplatePath )
118
117
}
119
118
120
- export interface ExecuteSamBuildArguments {
121
- baseBuildDir : string
122
- channelLogger : Pick < ChannelLogger , 'info' >
123
- codeDir : string
124
- inputTemplatePath : string
125
- manifestPath ?: string
126
- environmentVariables ?: NodeJS . ProcessEnv
127
- samProcessInvoker : SamCliProcessInvoker
128
- useContainer ?: boolean
129
- }
130
-
131
- export async function executeSamBuild ( {
132
- baseBuildDir,
133
- channelLogger,
134
- codeDir,
135
- inputTemplatePath,
136
- manifestPath,
137
- environmentVariables,
138
- samProcessInvoker,
139
- useContainer,
140
- } : ExecuteSamBuildArguments ) : Promise < string > {
141
- channelLogger . info ( 'AWS.output.building.sam.application' , 'Building SAM Application...' )
142
-
143
- const samBuildOutputFolder = path . join ( baseBuildDir , 'output' )
144
-
145
- const samCliArgs : SamCliBuildInvocationArguments = {
146
- buildDir : samBuildOutputFolder ,
147
- baseDir : codeDir ,
148
- templatePath : inputTemplatePath ,
149
- invoker : samProcessInvoker ,
150
- manifestPath,
151
- environmentVariables,
152
- useContainer,
153
- }
154
- await new SamCliBuildInvocation ( samCliArgs ) . execute ( )
155
-
156
- channelLogger . info ( 'AWS.output.building.sam.application.complete' , 'Build complete.' )
157
-
158
- return path . join ( samBuildOutputFolder , 'template.yaml' )
159
- }
160
-
161
119
/**
162
120
* Prepares and invokes a lambda function via `sam local invoke`.
163
121
*
164
122
* @param ctx
165
123
* @param config
166
- * @param onAfterBuild Called after `executeSamBuild ()`
124
+ * @param onAfterBuild Called after `SamCliBuildInvocation.execute ()`
167
125
*/
168
126
export async function invokeLambdaFunction (
169
127
ctx : ExtContext ,
@@ -175,25 +133,29 @@ export async function invokeLambdaFunction(
175
133
ctx . chanLogger . info ( 'AWS.output.sam.local.start' , 'Preparing to run {0} locally...' , config . handlerName )
176
134
177
135
const processInvoker = new DefaultValidatingSamCliProcessInvoker ( { } )
178
- const buildArgs : ExecuteSamBuildArguments = {
179
- baseBuildDir : config . baseBuildDir ! ,
180
- channelLogger : ctx . chanLogger ,
181
- codeDir : config . codeRoot ,
182
- inputTemplatePath : config . samTemplatePath ! ,
136
+
137
+ ctx . chanLogger . info ( 'AWS.output.building.sam.application' , 'Building SAM Application...' )
138
+ const samBuildOutputFolder = path . join ( config . baseBuildDir ! , 'output' )
139
+ const samCliArgs : SamCliBuildInvocationArguments = {
140
+ buildDir : samBuildOutputFolder ,
141
+ baseDir : config . codeRoot ,
142
+ templatePath : config . samTemplatePath ! ,
143
+ invoker : processInvoker ,
183
144
manifestPath : config . manifestPath ,
184
- samProcessInvoker : processInvoker ,
145
+ environmentVariables : { } ,
185
146
useContainer : config . sam ?. containerBuild || false ,
186
- environmentVariables : config . lambda ?. environmentVariables ,
187
147
}
188
-
189
148
if ( ! config . noDebug ) {
190
- buildArgs . environmentVariables = {
149
+ // Needed at least for dotnet case; harmless for others.
150
+ samCliArgs . environmentVariables = {
191
151
SAM_BUILD_MODE : 'debug' ,
192
152
}
193
153
}
154
+ await new SamCliBuildInvocation ( samCliArgs ) . execute ( )
155
+ ctx . chanLogger . info ( 'AWS.output.building.sam.application.complete' , 'Build complete.' )
194
156
195
157
// XXX: reassignment
196
- config . samTemplatePath = await executeSamBuild ( buildArgs )
158
+ config . samTemplatePath = path . join ( samBuildOutputFolder , 'template.yaml' )
197
159
delete config . invokeTarget // Must not be used beyond this point.
198
160
199
161
await onAfterBuild ( )
0 commit comments