I am using Powershell (version 5.1.17763.1007), and wish to combine two pipelines into one. Their contents are very similar; They recursively look for Python files from a folder into it's subfolders, and generate linting-reports for these Python files, using Pylint and prospector respectively (see https://www.pylint.org/ and https://pypi.org/project/prospector/ )
$path_to_files = "C:\Users\$env:UserName\Desktop\my_project_folder\linter_reports"
# Get all Python modules in folder and generate Pylint reports
Get-ChildItem -Path $path_to_files -Recurse -Filter *.py |
ForEach-Object { pylint $_.Name |
Out-File -FilePath "pylint_results_$($_.Name.TrimEnd(".py")).txt"
}
# Get all Python modules in folder and generate Prospector reports
Get-ChildItem -Path $path_to_files -Recurse -Filter *.py |
ForEach-Object { prospector $_.Name |
Out-File -FilePath "prospector_results_$($_.Name.TrimEnd(".py")).txt"
}
I have experimented with the Tee-Object Cmdlet (https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/tee-object?view=powershell-7), is that the best approach? I am looking for something like this (pseudo-code):
Get-ChildItem -Path $path_to_files -Recurse -Filter *.py |
ForEach-Object Tee-Object { pylint $_.Name |
Out-File -FilePath "pylint_results_$($_.Name.TrimEnd(".py")).txt"
} |
{ prospector$_.Name |
Out-File -FilePath "prospector_results_$($_.Name.TrimEnd(".py")).txt"
}