mirror of
https://github.com/zhigang1992/replace-in-file.git
synced 2026-04-29 13:15:33 +08:00
Tweaks to readme
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user