JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 57
  • Score
    100M100P100Q62934F

Pragmas and console statements remover

Package Exports

  • groundskeeper

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (groundskeeper) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

groundskeeper

This is a small utility to remove forgotten consoles and specific blocks of code from Javascript files.

It just happens that I forget a lot to remove console statements when moving code to production... at the same time I like to do a lot of validations while in development enviroment, validations that are not really needed when in production mode.

This tool is exactly that tool that removes all those useless stuff.

Requirements

  • nodejs
  • npm - If you're using a recent version of nodejs it should be already installed

Instalation

The easiest way is to use npm

npm install groundskeeper -g

Usage

groundskeeper [options] -i <input folder> -o <output folder>

Altough several options can be given, example:

  • To remove specific blocks of code, just insert comments specifying which block do you want to remove. Those comments must resemble the xml/html tags. By default all blocks named validation and development are removed.
function merge(target, source) {
    var k;

    //<validation>
    if (!is.object(target) || !is.object(source)) {
        throw new Error('Argument given must be of type Object');
    }
    //</validation>

    for (k in source) {
        if (source.hasOwnProperty(k) && !target[k]) {
            target[k] = source[k];
        }
    }

    return target;
}

To remove the following block just type:

groundskeeper -p validation -i file.js -o output.js
  • If you want to not remove console statments:
groundskeeper -c false -i file.js -o output.js

Options

-h, --help               output usage information
-V, --version            output the version number
-i, --input <path>       input folder, defaults to current folder
-o, --output <path>      output folder, defaults to ./clean
-c, --console [boolean]  enable the removal of console statements
-p, --pragmas <names>    comma-delimited <names> to remove, defaults to validation, development
-v, --verbose [boolean]  outputs current state of procedure
--list                   display list of console methods that will be removed

Tests

Tests are ran using mocha and jscoverage you can install mocha with npm install, but you'll need to clone and install jscoverage from this repository

To issue the tests, take a look at the Makefile, but in short, it's just a matter of doing:

make test

If you want to see the code coverage, just write:

make lib-cov && make test-cov

TODO

  • Finish tests

License

Copyright (c) 2012 Luís Couto Licensed under the MIT License