Created
August 18, 2017 17:27
-
-
Save jehugaleahsa/7f1b7cc5ffdb50fd023842b7485e8dea to your computer and use it in GitHub Desktop.
A simple PowerShell script to count the lines of code in a solution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$path = "C:\path\to\solution\folder" | |
$files = Get-ChildItem -Path $path -Include *.cs,*.ts,*.vb -Recurse ` | |
| ? { $_.FullName -notmatch ".*\\obj\\.*" } ` | |
| ? { $_.FullName -notmatch ".*\\node_modules\.*" } | |
$shortNames = $files | % { | |
$fullName = $_.FullName | |
$lines = [System.IO.File]::ReadAllLines($fullName) | |
$lines = $lines | ? { -not [System.String]::IsNullOrWhiteSpace($_) } | |
$data = @{}; | |
$data.Name = $_.Name | |
$data.LineCount = $lines.Length | |
New-Object -TypeName PSObject -Property $data | |
} | Sort-Object -Property LineCount -Descending | |
#$biggest = $shortNames | Select-Object -First 100 | |
$count = $shortNames | Measure-Object -Sum -Average -Property LineCount | |
Write-Host $count.Sum $count.Average |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment