Skip to content

devtrw/minerr-strip

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

minerr-strip

Strips minErr error messages from your build.

Install

npm install --save-dev minerr-strip

Example

This is essentially how the plugin is used in the gulp-minerr-strip package.

/**
 * @param {MinErrBuilderOptions} options
 */
function minerrStrip( options ) {
  'use strict';

  try {
    var minErrBuilder = new MinErrBuilder( options );
  } catch ( error ) {
    throw new PluginError( PLUGIN_NAME, error );
  }

  return through.obj(
    function transform( file, enc, done ) {
      var _this = this;

      if ( file.isNull() ) {
        this.push( file );

        return done();
      }

      function processFileContents(contents) {
        try {
          return minErrBuilder.processModule( contents );
        } catch (error) {
          _this.emit( 'error', new PluginError( PLUGIN_NAME, error) );
        }
      }

      if ( file.isBuffer() ) {
        file.contents = new Buffer( processFileContents( file.contents ) );
        this.push( file );

        return done();
      }

      if (!file.isStream()) {
        // Can there be another type?
        this.emit(
          'error',
          new PluginError( PLUGIN_NAME, 'File type was not buffer, stream or null and is therefor not supported' )
        );

        return done();
      }

      file.contents.pipe( es.wait( function ( err, data ) {
        file.contents = es.readArray( [ processFileContents( data ) ] );
        _this.push( file );
        done();
      } ) );

    },
    function flush( done ) {
      try {
        minErrBuilder.flushErrorConfig();
      } catch ( error ) {
        this.emit( 'error', new PluginError( PLUGIN_NAME, error ) );
      }

      return done();
    }
  );
}

Contributing

Pull requests are welcome! Remember to keep the following rules in mind:

  • All features or bug fixes must be documented by one or more specs. We use Jasmine.
  • Submissions must pass JSHint. Run gulp lint to check this.
  • Instead of complex inheritance hierarchies, we prefer simple objects. We use prototypical inheritance only when absolutely necessary.
  • We love functions and closures and, whenever possible, prefer them over objects.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •