@@ -8,9 +8,12 @@ const defaultOptions = {
8
8
} ;
9
9
10
10
const generateManifest = ( options = defaultOptions , targetFile ) => {
11
- const addBundleLicenseEntry = typeof options . addBundleLicenseEntry === 'boolean' ? options . addBundleLicenseEntry : true ;
12
- const bundleLicenseValue = typeof options . bundleLicenseValue === 'string' ? options . bundleLicenseValue : 'relative-path' ;
13
- const licenseFileRegex = typeof options . licenseFileRegex === 'string' ? options . licenseFileRegex : '^LICENSE(\\.txt)?$' ;
11
+ const addBundleLicenseEntry =
12
+ typeof options . addBundleLicenseEntry === 'boolean' ? options . addBundleLicenseEntry : true ;
13
+ const bundleLicenseValue =
14
+ typeof options . bundleLicenseValue === 'string' ? options . bundleLicenseValue : 'relative-path' ;
15
+ const licenseFileRegex =
16
+ typeof options . licenseFileRegex === 'string' ? options . licenseFileRegex : '^LICENSE(\\.txt)?$' ;
14
17
const defaultActivator = './' + targetFile . substring ( targetFile . lastIndexOf ( path . sep ) + 1 ) ;
15
18
const packageString = fs . readFileSync ( path . resolve ( 'package.json' ) ) . toString ( 'utf8' ) ;
16
19
const packageJson = JSON . parse ( packageString ) ;
@@ -43,10 +46,11 @@ const generateManifest = (options = defaultOptions, targetFile) => {
43
46
}
44
47
45
48
if ( addBundleLicenseEntry ) {
46
- const files = fs . readdirSync ( path . resolve ( ) , { withFileTypes : true } )
47
- . filter ( item => ! item . isDirectory ( ) )
48
- . map ( item => item . name )
49
- . filter ( item => item . match ( new RegExp ( licenseFileRegex ) ) ) ;
49
+ const files = fs
50
+ . readdirSync ( path . resolve ( ) , { withFileTypes : true } )
51
+ . filter ( ( item ) => ! item . isDirectory ( ) )
52
+ . map ( ( item ) => item . name )
53
+ . filter ( ( item ) => item . match ( new RegExp ( licenseFileRegex ) ) ) ;
50
54
51
55
if ( files . length ) {
52
56
switch ( bundleLicenseValue ) {
@@ -74,7 +78,7 @@ const generateManifest = (options = defaultOptions, targetFile) => {
74
78
fs . mkdirSync ( targetFolder , { recursive : true } ) ; // ensure folder is created
75
79
76
80
fs . writeFileSync ( targetPath , JSON . stringify ( finalContent , null , 4 ) , { encoding : 'utf8' } ) ;
77
- }
81
+ } ;
78
82
79
83
module . exports = {
80
84
generateManifest,
0 commit comments