Skip to content

Commit ce98a40

Browse files
Add Alternative Code Paths Depending on Parameters (Azure#13962)
* Add alternative code paths depending on parameters. * SilentlyContinue before explicit error if npm is not detected
1 parent 3190119 commit ce98a40

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

eng/scripts/Language-Settings.ps1

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,43 @@ $packagePattern = "*.tgz"
66
$MetadataUri = "https://raw.githubusercontent.com/Azure/azure-sdk/master/_data/releases/latest/js-packages.csv"
77
$BlobStorageUrl = "https://azuresdkdocs.blob.core.windows.net/%24web?restype=container&comp=list&prefix=javascript%2F&delimiter=%2F"
88

9+
function Confirm-NodeInstallation
10+
{
11+
if (!(Get-Command npm -ErrorAction SilentlyContinue))
12+
{
13+
LogError "Could not locate npm. Install NodeJS (includes npm and npx) https://nodejs.org/en/download"
14+
exit 1
15+
}
16+
}
17+
918
function Get-javascript-PackageInfoFromRepo ($pkgPath, $serviceDirectory, $pkgName)
1019
{
1120
$projectPath = Join-Path $pkgPath "package.json"
1221
if (Test-Path $projectPath)
1322
{
1423
$projectJson = Get-Content $projectPath | ConvertFrom-Json
1524
$jsStylePkgName = $projectJson.name.Replace("@", "").Replace("/", "-")
16-
if ($pkgName -eq "$jsStylePkgName" -or $pkgName -eq $projectJson.name)
25+
if ($pkgName -and ($pkgName -ne $jsStylePkgName -and $pkgName -ne $projectJson.name))
1726
{
18-
$pkgProp = [PackageProps]::new($projectJson.name, $projectJson.version, $pkgPath, $serviceDirectory)
19-
$pkgProp.SdkType = $projectJson.psobject.properties['sdk-type'].value
20-
if ($projectJson.name.StartsWith("@azure/arm"))
21-
{
22-
$pkgProp.SdkType = "mgmt"
23-
}
24-
$pkgProp.IsNewSdk = $pkgProp.SdkType -eq "client"
25-
$pkgProp.ArtifactName = $jsStylePkgName
26-
return $pkgProp
27+
return $null
28+
}
29+
$pkgProp = [PackageProps]::new($projectJson.name, $projectJson.version, $pkgPath, $serviceDirectory)
30+
$pkgProp.SdkType = $projectJson.psobject.properties['sdk-type'].value
31+
if ($projectJson.name.StartsWith("@azure/arm"))
32+
{
33+
$pkgProp.SdkType = "mgmt"
2734
}
35+
$pkgProp.IsNewSdk = $pkgProp.SdkType -eq "client"
36+
$pkgProp.ArtifactName = $jsStylePkgName
37+
return $pkgProp
2838
}
2939
return $null
3040
}
3141

3242
# Returns the npm publish status of a package id and version.
3343
function IsNPMPackageVersionPublished ($pkgId, $pkgVersion)
3444
{
45+
Confirm-NodeInstallation
3546
$npmVersions = (npm show $pkgId versions)
3647
if ($LastExitCode -ne 0)
3748
{
@@ -256,6 +267,7 @@ function SetPackageVersion ($PackageName, $Version, $ServiceDirectory = $null, $
256267
$ReleaseDate = Get-Date -Format "yyyy-MM-dd"
257268
}
258269
Push-Location "$EngDir/tools/versioning"
270+
Confirm-NodeInstallation
259271
npm install
260272
$artifactName = $PackageName.Replace("@", "").Replace("/", "-")
261273
node ./set-version.js --artifact-name $artifactName --new-version $Version --release-date $ReleaseDate --repo-root $RepoRoot

0 commit comments

Comments
 (0)