Skip to content

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

@Unicycle77

Description

@Unicycle77

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions