【发布时间】:2022-02-09 22:47:42
【问题描述】:
我是 Powershell 新手,想通过 Powershell 脚本自动化一些流程。 如果失败,有什么方法可以获取 npm run build 的状态。目前,如果我没有添加条件,那么它会按顺序运行下一个命令,无论成功还是失败。
我已经添加了$ErrorActionPreference = "Stop",但它只适用于 cmdlet。
$exitcode = npm run build
#need exitcode as output to check
if ($exitcode -eq 0) {
Remove-Item -Path $spaNodeModulePath -Force -Recurse
mkdir $spaNodeModulePath
xcopy $libDistPath $spaNodeModulePath /e
Set-Location $spaPath
}
【问题讨论】:
标签: node.js powershell npm