Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
pshao25 committed Apr 6, 2023
1 parent eecb802 commit 9c056d1
Showing 1 changed file with 3 additions and 16 deletions.
19 changes: 3 additions & 16 deletions eng/common/scripts/TypeSpec-Project-Generate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,14 @@ function GetNpmPackageVersion([string]$packagePath) {
}

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
$root = Resolve-Path "$PSScriptRoot/../../.."
Push-Location $root
try {
#default to root/eng/emitter-package.json but you can override by writing
Expand All @@ -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
Expand All @@ -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 }
}
Expand Down Expand Up @@ -108,9 +97,7 @@ function NpmInstallForProject([string]$workingDirectory) {
Remove-Item -Path "package-lock.json" -Force
}

if (!($env:SKIPINSTALL)) {
NpmInstallAtRoot
}
NpmInstallAtRoot
}
finally {
Pop-Location
Expand Down

0 comments on commit 9c056d1

Please sign in to comment.