-
Notifications
You must be signed in to change notification settings - Fork 497
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add a LICENSE file * added license, thanks @bnb * script to print licenses * Change to GPL v3 I believe it is necessary because of fnm's dependencies. If it's not, I'd be happy to make it more open * Update package.json
- Loading branch information
Showing
3 changed files
with
718 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/usr/bin/env node | ||
|
||
const { execSync } = require("child_process"); | ||
|
||
const groupByMap = (xs, fn, mapFn) => { | ||
const grouped = {}; | ||
|
||
for (const x of xs) { | ||
const key = fn(x); | ||
grouped[key] = grouped[key] || []; | ||
grouped[key].push(mapFn(x)); | ||
} | ||
|
||
return grouped; | ||
}; | ||
|
||
const licenses = execSync('grep -r "license:" esy.lock') | ||
.toString() | ||
.split("\n") | ||
.map(x => x.trim()) | ||
.filter(Boolean) | ||
.map(line => { | ||
const [path, , license] = line.split(":"); | ||
const dependency = path | ||
.split("/") | ||
.slice(1) | ||
.join("/") | ||
.match(/^(.+)\/[^/]+$/)[1]; | ||
return { dependency, license: JSON.parse(license.trim()) }; | ||
}); | ||
|
||
const byLicense = groupByMap( | ||
licenses, | ||
({ license }) => license, | ||
({ dependency }) => dependency | ||
); | ||
|
||
for (const [license, packages] of Object.entries(byLicense)) { | ||
console.log(`${license}:`); | ||
for (const package of packages) { | ||
console.log(` - ${package}`); | ||
} | ||
} |
Oops, something went wrong.