Created
June 27, 2019 13:44
-
-
Save mjul/ccffb6c30cc808b07f198d2353727d64 to your computer and use it in GitHub Desktop.
Get licenses for npm packages in node_modules
This file contains hidden or 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
write-host "Scanning..." | |
$packages = Get-ChildItem .\node_modules -Filter 'package.json' -Recurse | |
write-host ("Found {0} packages." -f $packages.Count) | |
$licenses = @() | |
write-host "Reading licenses..." | |
foreach ($p in $packages) { | |
$file = $p.FullName | |
$data = Get-Content -Path $file | ConvertFrom-Json | |
$license = $data.license | |
$licenses += $license; | |
} | |
$uniques = $licenses | sort-object | Get-Unique | sort-object | |
write-host ("Found {0} unique licenses." -f $uniques.Count) | |
$uniques | % { write-host $_ } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment