From e55aa6bb083b925e122be00e21ea07cf6f121f72 Mon Sep 17 00:00:00 2001 From: Timo Hocker Date: Wed, 25 Mar 2020 13:37:27 +0100 Subject: [PATCH] [no publish] fixes --- snippets/copyright/index.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/snippets/copyright/index.js b/snippets/copyright/index.js index e6a3767..3c80284 100644 --- a/snippets/copyright/index.js +++ b/snippets/copyright/index.js @@ -14,6 +14,8 @@ const fs = require ('fs-extra'); const path = require ('path'); /** + * scan all files and execute a mutation on them + * * @param {string} folder folder to scan * @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} software software name * @returns {string} copyright notice @@ -63,15 +67,18 @@ function get_copyright_notice (license = '', software = '') { } /** - * @param folder - * @param license + * scans a folder and fixes all copyright notices + * + * @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; - map_all_files (folder, (data) => { + await map_all_files (folder, (data) => { if (!regex.test (data)) return null; - return get_copyright_notice (license) + data.replace (regex, ''); + return get_copyright_notice (license, software) + data.replace (regex, ''); }); }