Skip to content

Commit f1c8bfc

Browse files
committed
Fixes broken links
1 parent 5e17abd commit f1c8bfc

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

scripts/UpdateLinks.ps1

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,15 +143,15 @@ function Construct-Path {
143143
if (Test-Path $BetaFilePath) {
144144
$V1Command = $Command.Replace("-MgBeta", "-Mg")
145145
$ConfirmV1Path = Join-Path $WorkLoadDocsPath "graph-powershell-1.0" "Microsoft.Graph.$Module" "$V1Command.md"
146-
if(Test-Path $ConfirmV1Path){
146+
if (Test-Path $ConfirmV1Path) {
147147
Add-Link -File $BetaFilePath -Module $Module -GraphProfile "beta" -Command $Command
148148
}
149149
}
150150

151151
if (Test-Path $V1FilePath) {
152152
$BetaCommand = $Command.Replace("-Mg", "-MgBeta")
153153
$ConfirmBetaPath = Join-Path $WorkLoadDocsPath "graph-powershell-beta" "Microsoft.Graph.Beta.$Module" "$BetaCommand.md"
154-
if(Test-Path $ConfirmBetaPath){
154+
if (Test-Path $ConfirmBetaPath) {
155155
Add-Link -File $V1FilePath -Module $Module -GraphProfile "v1.0" -Command $Command
156156
}
157157

@@ -192,13 +192,14 @@ function Add-Link {
192192

193193
}
194194

195-
$Block = $Matches[0]
196195
$Link = "> [!NOTE]`n> $LinkTitle [$CommandRename]($BaseUrl/$FullModuleName$View)`r`n`n## SYNTAX"
197196
$LinkOnEndOfDoc = "## RELATED LINKS`r`n[$CommandRename]($BaseUrl/$FullModuleName$View)"
198-
$NewBlock = $Block.Replace("## SYNTAX", $Link)
197+
$ConfirmCommandAvailability = Find-MgGraphCommand -Command $CommandRename
198+
if ($ConfirmCommandAvailability) {
199199
(Get-Content $File) |
200-
Foreach-Object { $_ -replace '## SYNTAX', $Link -replace '## RELATED LINKS', $LinkOnEndOfDoc } |
201-
Out-File $File
200+
Foreach-Object { $_ -replace '## SYNTAX', $Link -replace '## RELATED LINKS', $LinkOnEndOfDoc } |
201+
Out-File $File
202+
}
202203
}
203204
}
204205
catch {

0 commit comments

Comments
 (0)