Skip to content

Commit fe82be7

Browse files
committed
add progress notification for sam build
1 parent 1568065 commit fe82be7

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

packages/core/src/shared/sam/build.ts

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -235,18 +235,27 @@ export async function runBuild(arg?: TreeNode): Promise<SamBuildResult> {
235235
await updateRecentResponse(buildMementoRootKey, 'global', 'templatePath', templatePath)
236236

237237
try {
238-
const { path: samCliPath } = await getSamCliPathAndVersion()
238+
await vscode.window.withProgress(
239+
{
240+
location: vscode.ProgressLocation.Notification,
241+
},
242+
async (progress) => {
243+
progress.report({ message: `Building SAM template at ${params.template.uri.path}` })
239244

240-
// Create a child process to run the SAM build command
241-
const buildProcess = new ChildProcess(samCliPath, ['build', ...buildFlags], {
242-
spawnOptions: await addTelemetryEnvVar({
243-
cwd: params.projectRoot.fsPath,
244-
env: await getSpawnEnv(process.env),
245-
}),
246-
})
245+
const { path: samCliPath } = await getSamCliPathAndVersion()
246+
247+
// Create a child process to run the SAM build command
248+
const buildProcess = new ChildProcess(samCliPath, ['build', ...buildFlags], {
249+
spawnOptions: await addTelemetryEnvVar({
250+
cwd: params.projectRoot.fsPath,
251+
env: await getSpawnEnv(process.env),
252+
}),
253+
})
247254

248-
// Run SAM build in Terminal
249-
await runInTerminal(buildProcess, 'build')
255+
// Run SAM build in Terminal
256+
await runInTerminal(buildProcess, 'build')
257+
}
258+
)
250259

251260
await unregisterTemplateBuild(params.template.uri.path)
252261

packages/core/src/shared/sam/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ function isBuildInProgress(templatePath: string): boolean {
125125
*/
126126
export function throwIfTemplateIsBeingBuilt(templatePath: string) {
127127
if (isBuildInProgress(templatePath)) {
128-
throw new ToolkitError('Build in progress', { code: 'BuildInProgress' })
128+
throw new ToolkitError('Template is already being built', { code: 'BuildInProgress' })
129129
}
130130
}
131131

0 commit comments

Comments
 (0)