From a8981464dc599364734258c077fac600f6ef7a86 Mon Sep 17 00:00:00 2001 From: pshao25 <97225342+pshao25@users.noreply.github.com> Date: Mon, 13 Mar 2023 13:38:18 +0800 Subject: [PATCH 1/8] Install same emitter only once when generating SDK --- eng/common/scripts/Cadl-Project-Generate.ps1 | 84 +++++++++++++++++--- 1 file changed, 73 insertions(+), 11 deletions(-) diff --git a/eng/common/scripts/Cadl-Project-Generate.ps1 b/eng/common/scripts/Cadl-Project-Generate.ps1 index 3e7ee781b05..d069d2737b6 100644 --- a/eng/common/scripts/Cadl-Project-Generate.ps1 +++ b/eng/common/scripts/Cadl-Project-Generate.ps1 @@ -14,6 +14,78 @@ $ErrorActionPreference = "Stop" . $PSScriptRoot/common.ps1 Install-ModuleIfNotInstalled "powershell-yaml" "0.4.1" | Import-Module +function GetNpmPackageVersion([string]$packagePath) { + $packagePath = Resolve-Path $packagePath + $packageFolder = Split-Path -Parent $packagePath + $packageName = Split-Path -Leaf $packagePath + Push-Location $packageFolder + try { + $packageVersion = node -p -e "require('./$packageName').version" + return $packageVersion + } + finally { + Pop-Location + } +} + +function GetEmitterDependencyVersion([string]$packagePath) { + $emitterName = &$GetEmitterNameFn + $matchString = "`"$emitterName`": `"(.*?)`"" + If ((Get-Content -Raw $packagePath) -match $matchString) { + return $Matches[1] + } +} + +function NpmInstallAtRoot() { + $root = git rev-parse --show-toplevel + Push-Location $root + try { + #default to root/eng/emitter-package.json but you can override by writing + #Get-${Language}-EmitterPackageJsonPath in your Language-Settings.ps1 + $replacementPackageJson = "$PSScriptRoot/../../emitter-package.json" + if (Test-Path "Function:$GetEmitterPackageJsonPathFn") { + $replacementPackageJson = &$GetEmitterPackageJsonPathFn + } + + $emitterName = &$GetEmitterNameFn + $installedPath = Join-Path $root "node_modules" $emitterName "package.json" + if (Test-Path $installedPath) { + $installedVersion = GetNpmPackageVersion $installedPath + Write-Host "Installed emitter version: $installedVersion" + + $replacementVersion = GetEmitterDependencyVersion $replacementPackageJson + Write-Host "Replacement emitter version: $replacementVersion" + + if ($installedVersion -eq $replacementVersion) { + Write-Host "Emitter already installed. Skip installing." + return + } + } + + Write-Host "Installing package at $root" + + if (Test-Path "node_modules") { + Remove-Item -Path "node_modules" -Force -Recurse + } + + Write-Host("Copying package.json from $replacementPackageJson") + Copy-Item -Path $replacementPackageJson -Destination "package.json" -Force + npm install --no-lock-file + + if (Test-Path "package.json") { + Remove-Item -Path "package.json" -Force + } + if (Test-Path "package-lock.json") { + Remove-Item -Path "package-lock.json" -Force + } + + if ($LASTEXITCODE) { exit $LASTEXITCODE } + } + finally { + Pop-Location + } +} + function NpmInstallForProject([string]$workingDirectory) { Push-Location $workingDirectory try { @@ -36,17 +108,7 @@ function NpmInstallForProject([string]$workingDirectory) { Remove-Item -Path "package-lock.json" -Force } - #default to root/eng/emitter-package.json but you can override by writing - #Get-${Language}-EmitterPackageJsonPath in your Language-Settings.ps1 - $replacementPackageJson = "$PSScriptRoot/../../emitter-package.json" - if (Test-Path "Function:$GetEmitterPackageJsonPathFn") { - $replacementPackageJson = &$GetEmitterPackageJsonPathFn - } - - Write-Host("Copying package.json from $replacementPackageJson") - Copy-Item -Path $replacementPackageJson -Destination "package.json" -Force - npm install --no-lock-file - if ($LASTEXITCODE) { exit $LASTEXITCODE } + NpmInstallAtRoot } finally { Pop-Location From 38b8f4d33ab71eace4cca644b460724583b13a2e Mon Sep 17 00:00:00 2001 From: pshao25 <97225342+pshao25@users.noreply.github.com> Date: Mon, 20 Mar 2023 16:22:49 +0800 Subject: [PATCH 2/8] Update --- .../scripts/TypeSpec-Project-Generate.ps1 | 84 ++++++++++++++++--- 1 file changed, 73 insertions(+), 11 deletions(-) diff --git a/eng/common/scripts/TypeSpec-Project-Generate.ps1 b/eng/common/scripts/TypeSpec-Project-Generate.ps1 index feba00d37ed..e5dc439e8cb 100644 --- a/eng/common/scripts/TypeSpec-Project-Generate.ps1 +++ b/eng/common/scripts/TypeSpec-Project-Generate.ps1 @@ -14,6 +14,78 @@ $ErrorActionPreference = "Stop" . $PSScriptRoot/common.ps1 Install-ModuleIfNotInstalled "powershell-yaml" "0.4.1" | Import-Module +function GetNpmPackageVersion([string]$packagePath) { + $packagePath = Resolve-Path $packagePath + $packageFolder = Split-Path -Parent $packagePath + $packageName = Split-Path -Leaf $packagePath + Push-Location $packageFolder + try { + $packageVersion = node -p -e "require('./$packageName').version" + return $packageVersion + } + finally { + Pop-Location + } +} + +function GetEmitterDependencyVersion([string]$packagePath) { + $emitterName = &$GetEmitterNameFn + $matchString = "`"$emitterName`": `"(.*?)`"" + If ((Get-Content -Raw $packagePath) -match $matchString) { + return $Matches[1] + } +} + +function NpmInstallAtRoot() { + $root = git rev-parse --show-toplevel + Push-Location $root + try { + #default to root/eng/emitter-package.json but you can override by writing + #Get-${Language}-EmitterPackageJsonPath in your Language-Settings.ps1 + $replacementPackageJson = "$PSScriptRoot/../../emitter-package.json" + if (Test-Path "Function:$GetEmitterPackageJsonPathFn") { + $replacementPackageJson = &$GetEmitterPackageJsonPathFn + } + + $emitterName = &$GetEmitterNameFn + $installedPath = Join-Path $root "node_modules" $emitterName "package.json" + if (Test-Path $installedPath) { + $installedVersion = GetNpmPackageVersion $installedPath + Write-Host "Installed emitter version: $installedVersion" + + $replacementVersion = GetEmitterDependencyVersion $replacementPackageJson + Write-Host "Replacement emitter version: $replacementVersion" + + if ($installedVersion -eq $replacementVersion) { + Write-Host "Emitter already installed. Skip installing." + return + } + } + + Write-Host "Installing package at $root" + + if (Test-Path "node_modules") { + Remove-Item -Path "node_modules" -Force -Recurse + } + + Write-Host("Copying package.json from $replacementPackageJson") + Copy-Item -Path $replacementPackageJson -Destination "package.json" -Force + npm install --no-lock-file + + if (Test-Path "package.json") { + Remove-Item -Path "package.json" -Force + } + if (Test-Path "package-lock.json") { + Remove-Item -Path "package-lock.json" -Force + } + + if ($LASTEXITCODE) { exit $LASTEXITCODE } + } + finally { + Pop-Location + } +} + function NpmInstallForProject([string]$workingDirectory) { Push-Location $workingDirectory try { @@ -36,17 +108,7 @@ function NpmInstallForProject([string]$workingDirectory) { Remove-Item -Path "package-lock.json" -Force } - #default to root/eng/emitter-package.json but you can override by writing - #Get-${Language}-EmitterPackageJsonPath in your Language-Settings.ps1 - $replacementPackageJson = "$PSScriptRoot/../../emitter-package.json" - if (Test-Path "Function:$GetEmitterPackageJsonPathFn") { - $replacementPackageJson = &$GetEmitterPackageJsonPathFn - } - - Write-Host("Copying package.json from $replacementPackageJson") - Copy-Item -Path $replacementPackageJson -Destination "package.json" -Force - npm install --no-lock-file - if ($LASTEXITCODE) { exit $LASTEXITCODE } + NpmInstallAtRoot } finally { Pop-Location From 054bd5346e288d2016d073ccb1fabebc82463b74 Mon Sep 17 00:00:00 2001 From: pshao25 <97225342+pshao25@users.noreply.github.com> Date: Wed, 22 Mar 2023 14:20:45 +0800 Subject: [PATCH 3/8] Add lock --- eng/common/scripts/Cadl-Project-Generate.ps1 | 84 +++---------------- eng/common/scripts/Helpers/Lock-Helpers.ps1 | 19 +++++ .../scripts/TypeSpec-Project-Generate.ps1 | 3 + eng/common/scripts/common.ps1 | 1 + 4 files changed, 34 insertions(+), 73 deletions(-) create mode 100644 eng/common/scripts/Helpers/Lock-Helpers.ps1 diff --git a/eng/common/scripts/Cadl-Project-Generate.ps1 b/eng/common/scripts/Cadl-Project-Generate.ps1 index d069d2737b6..3e7ee781b05 100644 --- a/eng/common/scripts/Cadl-Project-Generate.ps1 +++ b/eng/common/scripts/Cadl-Project-Generate.ps1 @@ -14,78 +14,6 @@ $ErrorActionPreference = "Stop" . $PSScriptRoot/common.ps1 Install-ModuleIfNotInstalled "powershell-yaml" "0.4.1" | Import-Module -function GetNpmPackageVersion([string]$packagePath) { - $packagePath = Resolve-Path $packagePath - $packageFolder = Split-Path -Parent $packagePath - $packageName = Split-Path -Leaf $packagePath - Push-Location $packageFolder - try { - $packageVersion = node -p -e "require('./$packageName').version" - return $packageVersion - } - finally { - Pop-Location - } -} - -function GetEmitterDependencyVersion([string]$packagePath) { - $emitterName = &$GetEmitterNameFn - $matchString = "`"$emitterName`": `"(.*?)`"" - If ((Get-Content -Raw $packagePath) -match $matchString) { - return $Matches[1] - } -} - -function NpmInstallAtRoot() { - $root = git rev-parse --show-toplevel - Push-Location $root - try { - #default to root/eng/emitter-package.json but you can override by writing - #Get-${Language}-EmitterPackageJsonPath in your Language-Settings.ps1 - $replacementPackageJson = "$PSScriptRoot/../../emitter-package.json" - if (Test-Path "Function:$GetEmitterPackageJsonPathFn") { - $replacementPackageJson = &$GetEmitterPackageJsonPathFn - } - - $emitterName = &$GetEmitterNameFn - $installedPath = Join-Path $root "node_modules" $emitterName "package.json" - if (Test-Path $installedPath) { - $installedVersion = GetNpmPackageVersion $installedPath - Write-Host "Installed emitter version: $installedVersion" - - $replacementVersion = GetEmitterDependencyVersion $replacementPackageJson - Write-Host "Replacement emitter version: $replacementVersion" - - if ($installedVersion -eq $replacementVersion) { - Write-Host "Emitter already installed. Skip installing." - return - } - } - - Write-Host "Installing package at $root" - - if (Test-Path "node_modules") { - Remove-Item -Path "node_modules" -Force -Recurse - } - - Write-Host("Copying package.json from $replacementPackageJson") - Copy-Item -Path $replacementPackageJson -Destination "package.json" -Force - npm install --no-lock-file - - if (Test-Path "package.json") { - Remove-Item -Path "package.json" -Force - } - if (Test-Path "package-lock.json") { - Remove-Item -Path "package-lock.json" -Force - } - - if ($LASTEXITCODE) { exit $LASTEXITCODE } - } - finally { - Pop-Location - } -} - function NpmInstallForProject([string]$workingDirectory) { Push-Location $workingDirectory try { @@ -108,7 +36,17 @@ function NpmInstallForProject([string]$workingDirectory) { Remove-Item -Path "package-lock.json" -Force } - NpmInstallAtRoot + #default to root/eng/emitter-package.json but you can override by writing + #Get-${Language}-EmitterPackageJsonPath in your Language-Settings.ps1 + $replacementPackageJson = "$PSScriptRoot/../../emitter-package.json" + if (Test-Path "Function:$GetEmitterPackageJsonPathFn") { + $replacementPackageJson = &$GetEmitterPackageJsonPathFn + } + + Write-Host("Copying package.json from $replacementPackageJson") + Copy-Item -Path $replacementPackageJson -Destination "package.json" -Force + npm install --no-lock-file + if ($LASTEXITCODE) { exit $LASTEXITCODE } } finally { Pop-Location diff --git a/eng/common/scripts/Helpers/Lock-Helpers.ps1 b/eng/common/scripts/Helpers/Lock-Helpers.ps1 new file mode 100644 index 00000000000..3a30dea188a --- /dev/null +++ b/eng/common/scripts/Helpers/Lock-Helpers.ps1 @@ -0,0 +1,19 @@ +function FileLockEnter([string]$FilePath) { + $FilePath = Resolve-Path $FilePath + while (Test-Path -Path $FilePath) { + Start-Sleep -Seconds 5 + } + + try { + New-item -Path $FilePath + } + catch { + # This means another process already create this lock file, so try to acquire the lock again. + FileLockEnter($FilePath) + } +} + +function FileLockExit([string]$FilePath) { + $FilePath = Resolve-Path $FilePath + Remove-Item $FilePath -Force +} \ No newline at end of file diff --git a/eng/common/scripts/TypeSpec-Project-Generate.ps1 b/eng/common/scripts/TypeSpec-Project-Generate.ps1 index e5dc439e8cb..149ed25bb2d 100644 --- a/eng/common/scripts/TypeSpec-Project-Generate.ps1 +++ b/eng/common/scripts/TypeSpec-Project-Generate.ps1 @@ -108,7 +108,10 @@ function NpmInstallForProject([string]$workingDirectory) { Remove-Item -Path "package-lock.json" -Force } + $lockFile = Join-Path (git rev-parse --show-toplevel) "temp.lock" + FileLockEnter($lockFile) NpmInstallAtRoot + FileLockExit($lockFile) } finally { Pop-Location diff --git a/eng/common/scripts/common.ps1 b/eng/common/scripts/common.ps1 index 8f9c707ee29..d796754d9af 100644 --- a/eng/common/scripts/common.ps1 +++ b/eng/common/scripts/common.ps1 @@ -16,6 +16,7 @@ $EngScriptsDir = Join-Path $EngDir "scripts" . (Join-Path $EngCommonScriptsDir artifact-metadata-parsing.ps1) . (Join-Path $EngCommonScriptsDir "Helpers" git-helpers.ps1) . (Join-Path $EngCommonScriptsDir "Helpers" Package-Helpers.ps1) +. (Join-Path $EngCommonScriptsDir "Helpers" Lock-Helpers.ps1) # Setting expected from common languages settings $Language = "Unknown" From 4ee0edc7188afe896d31bad4902144ce8d5cb892 Mon Sep 17 00:00:00 2001 From: pshao25 <97225342+pshao25@users.noreply.github.com> Date: Wed, 22 Mar 2023 17:52:46 +0800 Subject: [PATCH 4/8] UpdatE --- eng/common/scripts/Helpers/Lock-Helpers.ps1 | 2 -- 1 file changed, 2 deletions(-) diff --git a/eng/common/scripts/Helpers/Lock-Helpers.ps1 b/eng/common/scripts/Helpers/Lock-Helpers.ps1 index 3a30dea188a..c9317498774 100644 --- a/eng/common/scripts/Helpers/Lock-Helpers.ps1 +++ b/eng/common/scripts/Helpers/Lock-Helpers.ps1 @@ -1,5 +1,4 @@ function FileLockEnter([string]$FilePath) { - $FilePath = Resolve-Path $FilePath while (Test-Path -Path $FilePath) { Start-Sleep -Seconds 5 } @@ -14,6 +13,5 @@ function FileLockEnter([string]$FilePath) { } function FileLockExit([string]$FilePath) { - $FilePath = Resolve-Path $FilePath Remove-Item $FilePath -Force } \ No newline at end of file From eecb802fd7825eeeec8ac98cdb7aca875087d164 Mon Sep 17 00:00:00 2001 From: pshao25 <97225342+pshao25@users.noreply.github.com> Date: Fri, 31 Mar 2023 14:09:56 +0800 Subject: [PATCH 5/8] UpdatE --- eng/common/scripts/Helpers/Lock-Helpers.ps1 | 17 ----------------- .../scripts/TypeSpec-Project-Generate.ps1 | 7 +++---- eng/common/scripts/common.ps1 | 1 - 3 files changed, 3 insertions(+), 22 deletions(-) delete mode 100644 eng/common/scripts/Helpers/Lock-Helpers.ps1 diff --git a/eng/common/scripts/Helpers/Lock-Helpers.ps1 b/eng/common/scripts/Helpers/Lock-Helpers.ps1 deleted file mode 100644 index c9317498774..00000000000 --- a/eng/common/scripts/Helpers/Lock-Helpers.ps1 +++ /dev/null @@ -1,17 +0,0 @@ -function FileLockEnter([string]$FilePath) { - while (Test-Path -Path $FilePath) { - Start-Sleep -Seconds 5 - } - - try { - New-item -Path $FilePath - } - catch { - # This means another process already create this lock file, so try to acquire the lock again. - FileLockEnter($FilePath) - } -} - -function FileLockExit([string]$FilePath) { - Remove-Item $FilePath -Force -} \ No newline at end of file diff --git a/eng/common/scripts/TypeSpec-Project-Generate.ps1 b/eng/common/scripts/TypeSpec-Project-Generate.ps1 index 149ed25bb2d..06c7d6ec479 100644 --- a/eng/common/scripts/TypeSpec-Project-Generate.ps1 +++ b/eng/common/scripts/TypeSpec-Project-Generate.ps1 @@ -108,10 +108,9 @@ function NpmInstallForProject([string]$workingDirectory) { Remove-Item -Path "package-lock.json" -Force } - $lockFile = Join-Path (git rev-parse --show-toplevel) "temp.lock" - FileLockEnter($lockFile) - NpmInstallAtRoot - FileLockExit($lockFile) + if (!($env:SKIPINSTALL)) { + NpmInstallAtRoot + } } finally { Pop-Location diff --git a/eng/common/scripts/common.ps1 b/eng/common/scripts/common.ps1 index d796754d9af..8f9c707ee29 100644 --- a/eng/common/scripts/common.ps1 +++ b/eng/common/scripts/common.ps1 @@ -16,7 +16,6 @@ $EngScriptsDir = Join-Path $EngDir "scripts" . (Join-Path $EngCommonScriptsDir artifact-metadata-parsing.ps1) . (Join-Path $EngCommonScriptsDir "Helpers" git-helpers.ps1) . (Join-Path $EngCommonScriptsDir "Helpers" Package-Helpers.ps1) -. (Join-Path $EngCommonScriptsDir "Helpers" Lock-Helpers.ps1) # Setting expected from common languages settings $Language = "Unknown" From 9c056d1679f592ee7e55234b2792ee1613e21be3 Mon Sep 17 00:00:00 2001 From: pshao25 <97225342+pshao25@users.noreply.github.com> Date: Thu, 6 Apr 2023 13:55:22 +0800 Subject: [PATCH 6/8] Update --- .../scripts/TypeSpec-Project-Generate.ps1 | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/eng/common/scripts/TypeSpec-Project-Generate.ps1 b/eng/common/scripts/TypeSpec-Project-Generate.ps1 index 06c7d6ec479..3638202e4a2 100644 --- a/eng/common/scripts/TypeSpec-Project-Generate.ps1 +++ b/eng/common/scripts/TypeSpec-Project-Generate.ps1 @@ -29,7 +29,6 @@ function GetNpmPackageVersion([string]$packagePath) { } function GetEmitterDependencyVersion([string]$packagePath) { - $emitterName = &$GetEmitterNameFn $matchString = "`"$emitterName`": `"(.*?)`"" If ((Get-Content -Raw $packagePath) -match $matchString) { return $Matches[1] @@ -37,7 +36,7 @@ function GetEmitterDependencyVersion([string]$packagePath) { } function NpmInstallAtRoot() { - $root = git rev-parse --show-toplevel + $root = Resolve-Path "$PSScriptRoot/../../.." Push-Location $root try { #default to root/eng/emitter-package.json but you can override by writing @@ -47,7 +46,6 @@ function NpmInstallAtRoot() { $replacementPackageJson = &$GetEmitterPackageJsonPathFn } - $emitterName = &$GetEmitterNameFn $installedPath = Join-Path $root "node_modules" $emitterName "package.json" if (Test-Path $installedPath) { $installedVersion = GetNpmPackageVersion $installedPath @@ -68,16 +66,7 @@ function NpmInstallAtRoot() { Remove-Item -Path "node_modules" -Force -Recurse } - Write-Host("Copying package.json from $replacementPackageJson") - Copy-Item -Path $replacementPackageJson -Destination "package.json" -Force - npm install --no-lock-file - - if (Test-Path "package.json") { - Remove-Item -Path "package.json" -Force - } - if (Test-Path "package-lock.json") { - Remove-Item -Path "package-lock.json" -Force - } + npm install "$emitterName@$replacementVersion" --no-lock-file if ($LASTEXITCODE) { exit $LASTEXITCODE } } @@ -108,9 +97,7 @@ function NpmInstallForProject([string]$workingDirectory) { Remove-Item -Path "package-lock.json" -Force } - if (!($env:SKIPINSTALL)) { - NpmInstallAtRoot - } + NpmInstallAtRoot } finally { Pop-Location From fe7d415f1e7732ddba70d4e64cfc5df4c65ab28f Mon Sep 17 00:00:00 2001 From: pshao25 <97225342+pshao25@users.noreply.github.com> Date: Fri, 7 Apr 2023 12:47:29 +0800 Subject: [PATCH 7/8] Update --- .../scripts/TypeSpec-Project-Generate.ps1 | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/eng/common/scripts/TypeSpec-Project-Generate.ps1 b/eng/common/scripts/TypeSpec-Project-Generate.ps1 index 3638202e4a2..839e0c6182f 100644 --- a/eng/common/scripts/TypeSpec-Project-Generate.ps1 +++ b/eng/common/scripts/TypeSpec-Project-Generate.ps1 @@ -46,27 +46,40 @@ function NpmInstallAtRoot() { $replacementPackageJson = &$GetEmitterPackageJsonPathFn } + $replacementVersion = GetEmitterDependencyVersion $replacementPackageJson + Write-Host "Replacement emitter version: $replacementVersion" + $installedPath = Join-Path $root "node_modules" $emitterName "package.json" + Write-Host "Checking installed emitter at $installedPath" if (Test-Path $installedPath) { $installedVersion = GetNpmPackageVersion $installedPath Write-Host "Installed emitter version: $installedVersion" - $replacementVersion = GetEmitterDependencyVersion $replacementPackageJson - Write-Host "Replacement emitter version: $replacementVersion" - if ($installedVersion -eq $replacementVersion) { Write-Host "Emitter already installed. Skip installing." return } } - Write-Host "Installing package at $root" + Write-Host "Installing package at"(Get-Location) if (Test-Path "node_modules") { + Write-Host "Remove existing node_modules at"(Get-Location) Remove-Item -Path "node_modules" -Force -Recurse } - npm install "$emitterName@$replacementVersion" --no-lock-file + $hasPackageFile = Test-Path "package.json" + + $npmInstallCommand = "npm install --prefix $root $emitterName@$replacementVersion --no-package-lock --omit=dev" + Write-Host($npmInstallCommand) + Invoke-Expression $npmInstallCommand + + if ($hasPackageFile) { + git restore package.json + } + else { + rm package.json + } if ($LASTEXITCODE) { exit $LASTEXITCODE } } From e6ccda12c3d5a80b4361a0be0bc42fbfc154ac68 Mon Sep 17 00:00:00 2001 From: pshao25 <97225342+pshao25@users.noreply.github.com> Date: Mon, 10 Apr 2023 11:09:02 +0800 Subject: [PATCH 8/8] UpdatE --- eng/common/scripts/TypeSpec-Project-Generate.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/eng/common/scripts/TypeSpec-Project-Generate.ps1 b/eng/common/scripts/TypeSpec-Project-Generate.ps1 index 839e0c6182f..2ad896fd812 100644 --- a/eng/common/scripts/TypeSpec-Project-Generate.ps1 +++ b/eng/common/scripts/TypeSpec-Project-Generate.ps1 @@ -73,6 +73,7 @@ function NpmInstallAtRoot() { $npmInstallCommand = "npm install --prefix $root $emitterName@$replacementVersion --no-package-lock --omit=dev" Write-Host($npmInstallCommand) Invoke-Expression $npmInstallCommand + if ($LASTEXITCODE) { exit $LASTEXITCODE } if ($hasPackageFile) { git restore package.json