This repository has been archived by the owner on Dec 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Quentin MOUTY
committed
Oct 30, 2024
1 parent
044a046
commit 49c9bc5
Showing
4 changed files
with
405 additions
and
3 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
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,33 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const { execSync } = require('child_process'); | ||
|
||
// Run license-checker to generate a JSON file | ||
execSync('license-checker --json --production > licenses.json', { stdio: 'inherit' }); | ||
|
||
// Read the licenses.json file | ||
const licensesFilePath = path.join(__dirname, 'licenses.json'); | ||
const licensesData = JSON.parse(fs.readFileSync(licensesFilePath, 'utf8')); | ||
|
||
// Extract unique licenses and packages | ||
const licensesSet = new Set(); | ||
const packages = []; | ||
|
||
for (const [packageName, licenseInfo] of Object.entries(licensesData)) { | ||
const license = licenseInfo.licenses || 'Unknown'; | ||
licensesSet.add(license); | ||
packages.push(`${packageName}; ${license}`); | ||
} | ||
|
||
// Convert sets to arrays and sort them | ||
const licenses = Array.from(licensesSet).sort(); | ||
const sortedPackages = packages.sort(); | ||
|
||
// Generate the output string | ||
const output = `Licences:\n${licenses.join('\n')}\n\nPackages:\n${sortedPackages.join('\n')}`; | ||
|
||
// Write the output to a file | ||
const outputFilePath = path.join(__dirname, 'dist/LICENCES.txt'); | ||
fs.writeFileSync(outputFilePath, output, 'utf8'); | ||
|
||
console.log('License information has been written to licenses-output.txt'); |
Oops, something went wrong.