Skip to content

Instantly share code, notes, and snippets.

@amandabot
Created April 29, 2020 13:13
Show Gist options
  • Save amandabot/1dcfdab3d01edff7d5944570ee7316ec to your computer and use it in GitHub Desktop.
Save amandabot/1dcfdab3d01edff7d5944570ee7316ec to your computer and use it in GitHub Desktop.
Calculate size of an Angular project
Set-Location ".\dist\production"
Function Format-FileSize() {
Param ([int]$size)
If ($size -gt 1TB) {[string]::Format("{0:0.00} TB", $size / 1TB)}
ElseIf ($size -gt 1GB) {[string]::Format("{0:0.00} GB", $size / 1GB)}
ElseIf ($size -gt 1MB) {[string]::Format("{0:0.00} MB", $size / 1MB)}
ElseIf ($size -gt 1KB) {[string]::Format("{0:0.00} kB", $size / 1KB)}
ElseIf ($size -gt 0) {[string]::Format("{0:0.00} B", $size)}
Else {""}
}
$sizeEs5 = 0;
Get-ChildItem *es5*.js | ForEach-Object {
$sizeEs5 += $_.Length;
#Format-FileSize(($_).length)
#Write-Host($size)
}
$sizeEs6 = 0;
Get-ChildItem *es2015*.js | ForEach-Object {
$sizeEs6 += $_.Length;
#Format-FileSize(($_).length)
#Write-Host($size)
}
$totalEs5 = Format-FileSize($sizeEs5);
$totalEs6 = Format-FileSize($sizeEs6);
Write-Host("Total ES5: $totalEs5")
Write-Host("Total ES6: $totalEs6")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment