parameters:
  Directory: 'not-specified'
  IgnoreLinksFile: '$(Build.SourcesDirectory)/eng/ignore-links.txt'
  WorkingDirectory: '$(System.DefaultWorkingDirectory)'
  ScriptDirectory: 'eng/common/scripts'
  Recursive: $false
  CheckLinkGuidance: $true
  Urls: '(Get-ChildItem -Path ./ -Recurse -Include *.md)'
  BranchReplaceRegex: "^(${env:SYSTEM_PULLREQUEST_SOURCEREPOSITORYURI}.*/(?:blob|tree)/)master(/.*)$"
  BranchReplacementName: "${env:SYSTEM_PULLREQUEST_SOURCECOMMITID}"

steps:
  - task: PowerShell@2
    displayName: Link verification check
    inputs:
      pwsh: true
      workingDirectory: '${{ parameters.WorkingDirectory }}/${{ parameters.Directory }}'
      filePath: ${{ parameters.ScriptDirectory }}/Verify-Links.ps1
      arguments: >
        -urls ${{ parameters.Urls }}
        -rootUrl "file://${{ parameters.WorkingDirectory }}/${{ parameters.Directory }}"
        -recursive: ${{ parameters.Recursive }} 
        -ignoreLinksFile ${{ parameters.IgnoreLinksFile }}
        -branchReplaceRegex "${{ parameters.BranchReplaceRegex }}"
        -branchReplacementName ${{ parameters.BranchReplacementName }}
        -devOpsLogging: $true
        -checkLinkGuidance: ${{ parameters.CheckLinkGuidance }}
