[no publish] fixes

This commit is contained in:
Timo Hocker 2020-03-25 13:37:27 +01:00
parent 7a29ad0e92
commit e55aa6bb08

View File

@ -14,6 +14,8 @@ const fs = require ('fs-extra');
const path = require ('path'); const path = require ('path');
/** /**
* scan all files and execute a mutation on them
*
* @param {string} folder folder to scan * @param {string} folder folder to scan
* @param {Function} func function to execute on file contents * @param {Function} func function to execute on file contents
*/ */
@ -35,6 +37,8 @@ async function map_all_files (folder, func) {
} }
/** /**
* returns a copyright notice
*
* @param {string} license license name * @param {string} license license name
* @param {string} software software name * @param {string} software software name
* @returns {string} copyright notice * @returns {string} copyright notice
@ -63,15 +67,18 @@ function get_copyright_notice (license = '', software = '') {
} }
/** /**
* @param folder * scans a folder and fixes all copyright notices
* @param license *
* @param {string} folder folder to scan
* @param {string} license license name
* @param {string} software software name
*/ */
function fix_all_copy (folder, license) { async function fix_all_copy (folder, license = '', software = '') {
const regex = /\/\*\s+\*\sCopyright[\s\S]*?\*\//g; const regex = /\/\*\s+\*\sCopyright[\s\S]*?\*\//g;
map_all_files (folder, (data) => { await map_all_files (folder, (data) => {
if (!regex.test (data)) if (!regex.test (data))
return null; return null;
return get_copyright_notice (license) + data.replace (regex, ''); return get_copyright_notice (license, software) + data.replace (regex, '');
}); });
} }