Tweaks to readme

This commit is contained in:
Adam Reis
2018-03-22 11:47:57 +13:00
parent d94c3aaa49
commit 5e64df1c89
2 changed files with 6 additions and 8 deletions

View File

@@ -28,8 +28,8 @@ module.exports = function makeReplacements(contents, from, to, file) {
//Make replacements
from.forEach((item, i) => {
//`from` callback is called with a filename argument
//and returns string or regexp
//Call function if given, passing the filename
if (typeof item === 'function') {
item = item(file);
}
@@ -39,9 +39,10 @@ module.exports = function makeReplacements(contents, from, to, file) {
if (replacement === null) {
return;
}
//Call function if given, appending the filename
if (typeof replacement === 'function') {
const original = replacement;
//`to` callback is called with an additional filename argument
replacement = (...args) => original(...args, file);
}