Skip to content

Commit

Permalink
Update replace.js
Browse files Browse the repository at this point in the history
Hello. Exist situation when text equals null and in this case we won't get this file in the list of matches. If you don't mind please add these changes
  • Loading branch information
Dwarfess committed Mar 24, 2021
1 parent 38c0f16 commit 27b87e2
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions replace.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,14 @@ module.exports = function(options) {
if (isFile) {
var text = fs.readFileSync(file, "utf-8");

text = replacizeText(text, file);
if (canReplace && text !== null) {
fs.writeFileSync(file, text);
} else if (text) {
matched.push(text);
var replacizedText = replacizeText(text, file);

if (replacizedText !== null) {
if (canReplace) {
fs.writeFileSync(file, replacizedText);
} else {
matched.push({ text, path: file });
}
}
}
else if (stats.isDirectory() && options.recursive) {
Expand Down

0 comments on commit 27b87e2

Please sign in to comment.