outaTiME / grunt-replace

Replace text patterns with applause.
MIT License
411 stars 47 forks source link

Feature request: Log replacements without requiring verbose if not silent #103

Open Unicycle77 opened 2 years ago

Unicycle77 commented 2 years ago

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch grunt-replace@2.0.2 for the project I'm working on.

When upgrading from grunt-replace 0.4.0 to 2.0.2, we lost the logging of each replacement. With a large batch of replacements, it's very helpful to see these log entries, since they are the only indication of progress. Turning verbose mode on is not an option, because it applies to other modules. (in our case logging roughly 10 lines per file)

Here is the diff that solved my problem:

diff --git a/node_modules/grunt-replace/tasks/replace.js b/node_modules/grunt-replace/tasks/replace.js
index c0428b4..153fd7f 100644
--- a/node_modules/grunt-replace/tasks/replace.js
+++ b/node_modules/grunt-replace/tasks/replace.js
@@ -52,8 +52,8 @@ module.exports = function (grunt) {
           result = content;
         }

-        if (result !== false) {
-          grunt.verbose.writeln('Replace ' + chalk.cyan(source) + ' → ' +
+        if (result !== false && options.silent !== true) {
+          grunt.log.writeln('Replace ' + chalk.cyan(source) + ' → ' +
             chalk.green(target));
         }

This issue body was partially generated by patch-package.