Skip to content

Commit

Permalink
Merge pull request #24 from Dwarfess/patch-4
Browse files Browse the repository at this point in the history
Update replace.js
  • Loading branch information
ALMaclaine committed Mar 27, 2021
2 parents 38c0f16 + 27b87e2 commit d15e2b1
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 d15e2b1

Please sign in to comment.