* Build header for a file * @param {string} file - JS/TS file * @param {object} pkg - Package json object * @param {object} options - Options
(file, pkg, options)
| 71 | * @param {object} options - Options |
| 72 | */ |
| 73 | async function buildHeader(file, pkg, options) { |
| 74 | const license = |
| 75 | options.license || _.get(pkg, 'license') || options.defaultLicense; |
| 76 | const years = await getYears(file); |
| 77 | const params = expandLicense(license, options.customLicenseLines); |
| 78 | params.years = years.join(','); |
| 79 | const owner = getCopyrightOwner(pkg, options); |
| 80 | |
| 81 | const name = |
| 82 | options.copyrightIdentifer || |
| 83 | _.get(pkg, 'copyright.identifier') || |
| 84 | _.get(pkg, 'name') || |
| 85 | options.defaultCopyrightIdentifer; |
| 86 | |
| 87 | debug(owner, name, license); |
| 88 | |
| 89 | _.defaults(params, { |
| 90 | owner, |
| 91 | name, |
| 92 | license, |
| 93 | }); |
| 94 | debug('Params', params); |
| 95 | return params.template(params); |
| 96 | } |
| 97 | |
| 98 | function getCopyrightOwner(pkg, options) { |
| 99 | return ( |
no test coverage detected