1919 * and modified to specific requirement.
2020 */
2121
22- import path from 'node:path' ;
2322import fs from 'node:fs' ;
23+ import path from 'node:path' ;
2424
2525import commonjs from '@rollup/plugin-commonjs' ;
2626import json from '@rollup/plugin-json' ;
@@ -80,7 +80,7 @@ const bundleDependency = (
8080 'THIRD_PARTY_NOTICES' ,
8181 ) ,
8282 template ( dependencies ) {
83- const stringified_dependencies = dependencies . map ( dependency => {
83+ const stringifiedDependencies = dependencies . map ( dependency => {
8484 let arr = [ ] ;
8585 arr . push ( `Name: ${ dependency . name ?? 'N/A' } ` ) ;
8686 let url = dependency . homepage ?? dependency . repository ;
@@ -98,36 +98,58 @@ const bundleDependency = (
9898 } ) ;
9999
100100 // Manual license handling for chrome-devtools-frontend third_party
101- const tsConfig = JSON . parse ( fs . readFileSync ( path . join ( process . cwd ( ) , 'tsconfig.json' ) , 'utf-8' ) ) ;
102- const thirdPartyDirectories = tsConfig . include . filter ( location => {
103- return location . includes (
101+ const tsConfig = JSON . parse (
102+ fs . readFileSync (
103+ path . join ( process . cwd ( ) , 'tsconfig.json' ) ,
104+ 'utf-8' ,
105+ ) ,
106+ ) ;
107+ const thirdPartyDirectories = tsConfig . include . filter ( location =>
108+ location . includes (
104109 'node_modules/chrome-devtools-frontend/front_end/third_party' ,
105- ) ;
106- } ) ;
110+ ) ,
111+ ) ;
107112
108113 const manualLicenses = [ ] ;
109114 // Add chrome-devtools-frontend main license
110- const cdtfLicensePath = path . join ( process . cwd ( ) , 'node_modules/chrome-devtools-frontend/LICENSE' ) ;
115+ const cdtfLicensePath = path . join (
116+ process . cwd ( ) ,
117+ 'node_modules/chrome-devtools-frontend/LICENSE' ,
118+ ) ;
111119 if ( fs . existsSync ( cdtfLicensePath ) ) {
112- manualLicenses . push ( [ 'Name: chrome-devtools-frontend' , 'License: Apache-2.0' , '' , fs . readFileSync ( cdtfLicensePath , 'utf-8' ) ] . join ( '\n' ) ) ;
120+ manualLicenses . push (
121+ [
122+ 'Name: chrome-devtools-frontend' ,
123+ 'License: Apache-2.0' ,
124+ '' ,
125+ fs . readFileSync ( cdtfLicensePath , 'utf-8' ) ,
126+ ] . join ( '\n' ) ,
127+ ) ;
113128 }
114129
115130 for ( const thirdPartyDir of thirdPartyDirectories ) {
116131 const fullPath = path . join ( process . cwd ( ) , thirdPartyDir ) ;
117132 const licenseFile = path . join ( fullPath , 'LICENSE' ) ;
118133 if ( fs . existsSync ( licenseFile ) ) {
119- const name = path . basename ( thirdPartyDir ) ;
120- manualLicenses . push ( [ `Name: ${ name } ` , `License: Custom` , '' , fs . readFileSync ( licenseFile , 'utf-8' ) . replaceAll ( '\r' , '' ) ] . join ( '\n' ) ) ;
134+ const name = path . basename ( thirdPartyDir ) ;
135+ manualLicenses . push (
136+ [
137+ `Name: ${ name } ` ,
138+ `License:` ,
139+ '' ,
140+ fs . readFileSync ( licenseFile , 'utf-8' ) . replaceAll ( '\r' , '' ) ,
141+ ] . join ( '\n' ) ,
142+ ) ;
121143 }
122144 }
123-
145+
124146 if ( manualLicenses . length > 0 ) {
125- stringified_dependencies . push ( ...manualLicenses ) ;
147+ stringifiedDependencies . push ( ...manualLicenses ) ;
126148 }
127149
128150 const divider =
129151 '\n\n-------------------- DEPENDENCY DIVIDER --------------------\n\n' ;
130- return stringified_dependencies . join ( divider ) ;
152+ return stringifiedDependencies . join ( divider ) ;
131153 } ,
132154 } ,
133155 } ,
0 commit comments