Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

plugin-error

Package Overview
Dependencies
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

plugin-error - npm Package Compare versions

Comparing version 0.1.2 to 1.0.0

index.d.ts

69

index.js

@@ -1,11 +0,3 @@

/*!
* plugin-error <https://github.com/jonschlinkert/plugin-error>
*
* Copyright (c) 2015, Jon Schlinkert.
* Licensed under the MIT License.
*/
var util = require('util');
var red = require('ansi-red');
var cyan = require('ansi-cyan');
var colors = require('ansi-colors');
var extend = require('extend-shallow');

@@ -15,7 +7,2 @@ var differ = require('arr-diff');

/**
* Based on gulp-util PluginError (MIT Licensed)
* See: https://github.com/wearefractal/gulp-util
*/
var nonEnum = ['message', 'name', 'stack'];

@@ -34,3 +21,3 @@ var ignored = union(nonEnum, ['__safety', '_stack', 'plugin', 'showProperties', 'showStack']);

// if opts has an error, get details from it
// If opts has an error, get details from it
if (typeof opts.error === 'object') {

@@ -45,9 +32,13 @@ var keys = union(Object.keys(opts.error), nonEnum);

// opts object can override
// Opts object can override
props.forEach(function(prop) {
if (prop in opts) this[prop] = opts[prop];
if (prop in opts) {
this[prop] = opts[prop];
}
}, this);
// defaults
if (!this.name) this.name = 'Error';
// Defaults
if (!this.name) {
this.name = 'Error';
}
if (!this.stack) {

@@ -72,4 +63,8 @@

}
if (!this.plugin) throw new Error('Missing plugin name');
if (!this.message) throw new Error('Missing error message');
if (!this.plugin) {
throw new Error('Missing plugin name');
}
if (!this.message) {
throw new Error('Missing error message');
}
}

@@ -86,3 +81,5 @@

var details = this._messageDetails();
if (details !== '') msg += '\n' + details;
if (details !== '') {
msg += '\n' + details;
}
return msg;

@@ -96,3 +93,5 @@ };

PluginError.prototype._messageDetails = function() {
if (!this.showProperties) return '';
if (!this.showProperties) {
return '';
}

@@ -102,5 +101,8 @@ var props = differ(Object.keys(this), ignored);

if (len === 0) return '';
if (len === 0) {
return '';
}
var res = '', i = 0;
var res = '';
var i = 0;
while (len--) {

@@ -119,3 +121,3 @@ var prop = props[i++];

PluginError.prototype.toString = function () {
PluginError.prototype.toString = function() {
var detailsWithStack = function(stack) {

@@ -127,3 +129,3 @@ return this._messageWithDetails() + '\nStack:\n' + stack;

if (this.showStack) {
// if there is no wrapped error, use the stack captured in the PluginError ctor
// If there is no wrapped error, use the stack captured in the PluginError ctor
if (this.__safety) {

@@ -140,3 +142,3 @@ msg = this.__safety.stack;

return message(msg, this);
}
}

@@ -147,7 +149,7 @@ msg = this._messageWithDetails();

// format the output message
// Format the output message
function message(msg, thisArg) {
var sig = red(thisArg.name);
var sig = colors.red(thisArg.name);
sig += ' in plugin ';
sig += '"' + cyan(thisArg.plugin) + '"';
sig += '"' + colors.cyan(thisArg.plugin) + '"';
sig += '\n';

@@ -189,3 +191,6 @@ sig += msg;

function defaults(opts) {
return extend({showStack: false, showProperties: true}, opts);
return extend({
showStack: false,
showProperties: true,
}, opts);
}

@@ -192,0 +197,0 @@

{
"name": "plugin-error",
"description": "Error handling for vinyl plugins. Just an abstraction of what's in gulp-util with minor changes.",
"version": "0.1.2",
"homepage": "https://github.com/jonschlinkert/plugin-error",
"author": {
"name": "Jon Schlinkert",
"url": "https://github.com/jonschlinkert"
"version": "1.0.0",
"description": "Error handling for Vinyl plugins.",
"author": "Gulp Team <team@gulpjs.com> (http://gulpjs.com/)",
"contributors": [
"Jon Schlinkert <jon.schlinkert@sellside.com>",
"Blaine Bublitz <blaine.bublitz@gmail.com>"
],
"repository": "gulpjs/plugin-error",
"license": "MIT",
"engines": {
"node": ">= 0.10"
},
"repository": {
"type": "git",
"url": "git://github.com/jonschlinkert/plugin-error.git"
},
"bugs": {
"url": "https://github.com/jonschlinkert/plugin-error/issues"
},
"license": "MIT",
"main": "index.js",
"files": [
"LICENSE",
"index.d.ts",
"index.js"
],
"main": "index.js",
"engines": {
"node": ">=0.10.0"
},
"scripts": {
"test": "mocha"
"lint": "eslint . && jscs index.js test/",
"pretest": "npm run lint",
"test": "mocha --async-only && npm run test-types",
"test-types": "tsc -p test/types",
"cover": "istanbul cover _mocha --report lcovonly",
"coveralls": "npm run cover && istanbul-coveralls"
},
"dependencies": {
"ansi-cyan": "^0.1.1",
"ansi-red": "^0.1.1",
"arr-diff": "^1.0.1",
"arr-union": "^2.0.1",
"extend-shallow": "^1.1.2"
"ansi-colors": "^1.0.1",
"arr-diff": "^4.0.0",
"arr-union": "^3.1.0",
"extend-shallow": "^3.0.2"
},
"devDependencies": {
"mocha": "*",
"should": "*"
"eslint": "^1.7.3",
"eslint-config-gulp": "^2.0.0",
"expect": "^1.20.2",
"istanbul": "^0.4.3",
"istanbul-coveralls": "^1.0.3",
"jscs": "^2.3.5",
"jscs-preset-gulp": "^1.0.0",
"mocha": "^3.0.0",
"typescript": "^2.6.2"
},
"keywords": [
"error",
"plugin"
"plugin",
"gulp-util"
]
}

@@ -1,10 +0,12 @@

# plugin-error [![NPM version](https://badge.fury.io/js/plugin-error.svg)](http://badge.fury.io/js/plugin-error) [![Build Status](https://travis-ci.org/jonschlinkert/plugin-error.svg)](https://travis-ci.org/jonschlinkert/plugin-error)
<p align="center">
<a href="http://gulpjs.com">
<img height="257" width="114" src="https://raw.githubusercontent.com/gulpjs/artwork/master/gulp-2x.png">
</a>
</p>
> Error handling for vinyl plugins. Just an abstraction of what's in gulp-util with minor changes.
# plugin-error
Install with [npm](https://www.npmjs.com/)
[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][travis-image]][travis-url] [![AppVeyor Build Status][appveyor-image]][appveyor-url] [![Coveralls Status][coveralls-image]][coveralls-url] [![Gitter chat][gitter-image]][gitter-url]
```sh
$ npm i plugin-error --save
```
Error handling for Vinyl plugins.

@@ -15,24 +17,3 @@ ## Usage

var PluginError = require('plugin-error');
```
### new PluginError(pluginName, message[, options]);
**Params**
* `pluginName` should be the module name of your plugin
* `message` **{String|Object}**: may be a string or an existing error object
* `options` **{Object}**
**Behavior:**
* By default the stack will not be shown. Set `options.showStack` to true if you think the stack is important for your error.
* If you pass an error object as the message the stack will be pulled from that, otherwise one will be created.
* If you pass in a custom stack string you need to include the message along with that.
* Error properties will be included in `err.toString()`, but may be omitted by including `{showProperties: false}` in the options.
**Examples**
All of the following are acceptable forms of instantiation:
```javascript
var err = new PluginError('test', {

@@ -49,42 +30,42 @@ message: 'something broke'

var err = new PluginError('test', 'something broke', {showStack: true});
var err = new PluginError('test', 'something broke', { showStack: true });
var existingError = new Error('OMG');
var err = new PluginError('test', existingError, {showStack: true});
var err = new PluginError('test', existingError, { showStack: true });
```
## Related projects
## API
* [assemble](http://assemble.io): Static site generator for Grunt.js, Yeoman and Node.js. Used by Zurb Foundation, Zurb Ink, H5BP/Effeckt,… [more](http://assemble.io)
* [gulp-util](https://github.com/wearefractal/gulp-util#readme): Utility functions for gulp plugins
* [gulp](http://gulpjs.com): The streaming build system
* [generate](https://github.com/generate/generate): Project generator, for node.js.
* [verb](https://github.com/assemble/verb): Documentation generator for GitHub projects. Extremely powerful, easy to use, can generate anything from API… [more](https://github.com/assemble/verb)
### `new PluginError(pluginName, message[, options])`
## Running tests
Error constructor that takes:
* `pluginName` - a `String` that should be the module name of your plugin
* `message` - a `String` message or an existing `Error` object
* `options` - an `Object` of your options
Install dev dependencies:
**Behavior:**
```sh
$ npm i -d && npm test
```
* By default the stack will not be shown. Set `options.showStack` to true if you think the stack is important for your error.
* If you pass an error object as the message the stack will be pulled from that, otherwise one will be created.
* If you pass in a custom stack string you need to include the message along with that.
* Error properties will be included in `err.toString()`, but may be omitted by including `{ showProperties: false }` in the options.
## Contributing
## License
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/plugin-error/issues/new)
MIT
## Author
[downloads-image]: http://img.shields.io/npm/dm/plugin-error.svg
[npm-url]: https://www.npmjs.com/package/plugin-error
[npm-image]: http://img.shields.io/npm/v/plugin-error.svg
**Jon Schlinkert**
[travis-url]: https://travis-ci.org/gulpjs/plugin-error
[travis-image]: http://img.shields.io/travis/gulpjs/plugin-error.svg?label=travis-ci
+ [github/jonschlinkert](https://github.com/jonschlinkert)
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
[appveyor-url]: https://ci.appveyor.com/project/gulpjs/plugin-error
[appveyor-image]: https://img.shields.io/appveyor/ci/gulpjs/plugin-error.svg?label=appveyor
## License
[coveralls-url]: https://coveralls.io/r/gulpjs/plugin-error
[coveralls-image]: http://img.shields.io/coveralls/gulpjs/plugin-error/master.svg
Copyright © 2015 Jon Schlinkert
Released under the MIT license.
***
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on May 31, 2015._
[gitter-url]: https://gitter.im/gulpjs/gulp
[gitter-image]: https://badges.gitter.im/gulpjs/gulp.svg

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc