@@ -32,6 +32,22 @@ function Invoke-ScriptWithLogging {
3232 Write-Host " "
3333}
3434
35+
36+ $script :startTime = Get-Date
37+ $scriptName = $MyInvocation.MyCommand.Name
38+
39+ function Write-ElapsedTime {
40+ [CmdletBinding ()]
41+ param (
42+ [Parameter (Mandatory = $true )]
43+ [string ]$Message
44+ )
45+
46+ $elapsedTime = [math ]::Round(((Get-Date ) - $script :startTime ).TotalSeconds, 1 )
47+ Write-Host " [${scriptName} ] ${Message} . Total elapsed time: $elapsedTime seconds."
48+ Write-Host " "
49+ }
50+
3551function Get-GitHubApiHeaders {
3652 param (
3753 [Parameter (Mandatory = $false )]
@@ -265,6 +281,8 @@ else {
265281 }
266282}
267283
284+ Write-ElapsedTime " Spec retrieved"
285+
268286Push-Location $repoRootPath
269287
270288try {
@@ -273,10 +291,13 @@ try {
273291 exit $LASTEXITCODE
274292 }
275293
294+ Write-ElapsedTime " npm ci complete"
295+
276296 Invoke-ScriptWithLogging { npm run build - w $codegenFolderPath }
277297 if ($LASTEXITCODE -ne 0 ) {
278298 exit $LASTEXITCODE
279299 }
300+ Write-ElapsedTime " npm run build complete"
280301
281302 Set-Location $specificationFolderPath
282303 Invoke-ScriptWithLogging { npx tsp compile . -- stats -- trace @typespec / http- client- csharp }
@@ -285,9 +306,4 @@ finally {
285306 Pop-Location
286307}
287308
288- $scriptElapsed = $ (Get-Date ) - $scriptStartTime
289- $scriptElapsedSeconds = [math ]::Round($scriptElapsed.TotalSeconds , 1 )
290- $scriptName = $MyInvocation.MyCommand.Name
291-
292- Write-Host " ${scriptName} completed. Time: ${scriptElapsedSeconds} s"
293- Write-Host " "
309+ Write-ElapsedTime " Script completed"
0 commit comments