Git Product home page Git Product logo

grunt-remove-logging's Introduction

About

This task removes all console logging statements from your source code.

Getting Started

Install this plugin with the command:

npm install grunt-remove-logging

Next, add this line to your project's grunt file:

grunt.loadNpmTasks("grunt-remove-logging");

Lastly, add the configuration settings (see below) to your grunt file.

Documentation

This task has two required properties, src and dest. src is the path to your source file and dest is the file this task will write to (relative to the grunt.js file).

An example configuration looks like this:

grunt.initConfig({
  removelogging: {
    dist: {
      src: "js/application.js",
      dest: "js/application-clean.js",

      options: {
        // see below for options. this is optional.
      }
    }
  }
});

To run this task against multiple files and automatically overwrite them with the resultant output, omit the dest option:

grunt.initConfig({
  removelogging: {
    dist: {
      src: "dist/**/*.js" // Each file will be overwritten with the output!
    }
  }
});

Optional Configuration Properties

This plugin can be customized by specifying the following options:

  • replaceWith: A value to replace logging statements with. This option defaults to an empty string. If you use fancy statements like console && console.log("foo");, you may choose to specify a replaceWith value like 0; so that your scripts don't completely break.
  • namespace: An array of object names that logging methods are attached to. Defaults to [ 'console', 'window.console' ]. If you use a custom logger, like MyApp.logger.log(foo), you would set this option to [MyApp.logger].
  • methods: An array of method names to remove. Defaults to all the methods in the Firebug console API. This option is useful if you want to strip out all log methods, but keep warn for example.
  • verbose: Boolean value, whether to show count of logging statements removed for each file. Defaults to true. If false, a single summary line is logged to grunt instead.

Skipping Individual Statements

You can tell this task to keep specific logging statements by adding the comment directive /*RemoveLogging:skip*/ after the statement:

console.log("foo");/*RemoveLogging:skip*/

// or:

console.log("foo")/*RemoveLogging:skip*/;

// whitespace is fine too, whatever floats your boat:

console.log("foo") /* RemoveLogging:skip */;

grunt-remove-logging's People

Contributors

ehynds avatar shakyshane avatar hemanth avatar alonisser avatar beatfactor avatar nanoamp avatar

Watchers

James Cloos avatar Abe Fehr avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.