start.ps1 748 B

12345678910111213141516
  1. $ErrorActionPreference = 'Stop'
  2. Push-Location $PSScriptRoot
  3. try {
  4. if (-not (Get-Command node -ErrorAction SilentlyContinue)) {
  5. throw 'Node.js 24+ is required. Install it first, then run npm ci and npm start.'
  6. }
  7. $teamsNodeMajor = [int]((& node --version).Trim().TrimStart('v').Split('.')[0])
  8. if ($teamsNodeMajor -lt 24) { throw 'Node.js 24+ is required.' }
  9. if (-not (Test-Path -LiteralPath (Join-Path $PSScriptRoot 'node_modules/@azure/msal-node'))) {
  10. & npm.cmd ci
  11. if ($LASTEXITCODE -ne 0) { throw 'Dependency installation failed.' }
  12. }
  13. & node --env-file-if-exists=.env src/main.js
  14. if ($LASTEXITCODE -ne 0) { throw "Collector stopped with exit code $LASTEXITCODE." }
  15. }
  16. finally { Pop-Location }