Skip to content

Call npm.cmd on Windows in Export-AdfToArmTemplate #462 - #515

Merged
NowinskiK merged 1 commit into
developfrom
issue-462-npm-cmd
Oct 16, 2026
Merged

NowinskiK merged 1 commit into
developfrom
issue-462-npm-cmd

Conversation

@NowinskiK

Copy link
Copy Markdown
Member

Closes #462

Root cause

Export-AdfToArmTemplate called a bare npm, so on Windows PowerShell runs the npm.ps1 script that Node installs. Some npm versions' npm.ps1 sets Set-StrictMode -Version Latest and reads $MyInvocation.Statement, which only exists in PowerShell 7.4+. On Windows PowerShell 5.1 (the windows-2025 agents) this throws The property 'Statement' cannot be found on this object.

Changes

  • New private helper Invoke-AdfNpm (private/Invoke-AdfNpm.ps1): calls npm.cmd on Windows (skips npm.ps1) and npm elsewhere.
  • Behaviour change: a non-zero npm exit code now throws, so a failed npm i or npm run build export stops the export instead of being ignored.
  • Changelog entry under [Unreleased].

Tests

  • New unit tests in test/Export-AdfToArmTemplate-Npm.Tests.ps1 (which npm command is chosen, argument passing, failure on a non-zero exit code, the three npm calls of the export). They pass locally under both $ErrorActionPreference = 'Continue' and 'Stop'.
  • The end-to-end Export-AdfToArmTemplate.Tests.ps1 runs real npm and is verified by this PR's CI run.

🤖 Generated with Claude Code

On Windows, 'npm' runs npm.ps1, which in some npm versions reads
$MyInvocation.Statement under strict mode and fails on Windows
PowerShell 5.1 (windows-2025 agents). npm.cmd skips npm.ps1.
A failed npm command now stops the export instead of being ignored.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@NowinskiK
NowinskiK merged commit d045395 into develop Oct 16, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant