Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
{
"extends": "gulp"
"root": true,
"extends": [
"standard",
"gulp"
]
}
3 changes: 0 additions & 3 deletions .jscsrc

This file was deleted.

3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
sudo: false
language: node_js
node_js:
- 'stable'
- '8'
- '6'
- '4'
- '0.12'
- '0.10'
after_script:
- npm run coveralls
7 changes: 3 additions & 4 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
environment:
matrix:
# node.js
- nodejs_version: "0.10"
- nodejs_version: "0.12"
- nodejs_version: "4"
- nodejs_version: "6"
- nodejs_version: "stable"
- nodejs_version: "8"
- nodejs_version: "6"
- nodejs_version: "4"

install:
- ps: Install-Product node $env:nodejs_version
Expand Down
28 changes: 13 additions & 15 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var nonEnum = ['message', 'name', 'stack'];
var ignored = union(nonEnum, ['__safety', '_stack', 'plugin', 'showProperties', 'showStack']);
var props = ['fileName', 'lineNumber', 'message', 'name', 'plugin', 'showProperties', 'showStack', 'stack'];

function PluginError(plugin, message, options) {
function PluginError (plugin, message, options) {
if (!(this instanceof PluginError)) {
throw new Error('Call PluginError using new');
}
Expand All @@ -22,13 +22,13 @@ function PluginError(plugin, message, options) {
var keys = union(Object.keys(opts.error), nonEnum);

// These properties are not enumerable, so we have to add them explicitly.
keys.forEach(function(prop) {
keys.forEach(function (prop) {
self[prop] = opts.error[prop];
});
}

// Opts object can override
props.forEach(function(prop) {
props.forEach(function (prop) {
if (prop in opts) {
this[prop] = opts[prop];
}
Expand All @@ -39,7 +39,6 @@ function PluginError(plugin, message, options) {
this.name = 'Error';
}
if (!this.stack) {

/**
* `Error.captureStackTrace` appends a stack property which
* relies on the toString method of the object it is applied to.
Expand All @@ -50,10 +49,11 @@ function PluginError(plugin, message, options) {
*/

var safety = {};
safety.toString = function() {
safety.toString = function () {
return this._messageWithDetails() + '\nStack:';
}.bind(this);

// eslint-disable-next-line no-caller
Error.captureStackTrace(safety, arguments.callee || this.constructor);
this.__safety = safety;
}
Expand All @@ -71,7 +71,7 @@ util.inherits(PluginError, Error);
* Output a formatted message with details
*/

PluginError.prototype._messageWithDetails = function() {
PluginError.prototype._messageWithDetails = function () {
var msg = 'Message:\n ' + this.message;
var details = this._messageDetails();
if (details !== '') {
Expand All @@ -84,7 +84,7 @@ PluginError.prototype._messageWithDetails = function() {
* Output actual message details
*/

PluginError.prototype._messageDetails = function() {
PluginError.prototype._messageDetails = function () {
if (!this.showProperties) {
return '';
}
Expand All @@ -111,8 +111,8 @@ PluginError.prototype._messageDetails = function() {
* Override the `toString` method
*/

PluginError.prototype.toString = function() {
var detailsWithStack = function(stack) {
PluginError.prototype.toString = function () {
var detailsWithStack = function (stack) {
return this._messageWithDetails() + '\nStack:\n' + stack;
}.bind(this);

Expand All @@ -121,10 +121,8 @@ PluginError.prototype.toString = function() {
// If there is no wrapped error, use the stack captured in the PluginError ctor
if (this.__safety) {
msg = this.__safety.stack;

} else if (this._stack) {
msg = detailsWithStack(this._stack);

} else {
// Stack from wrapped error
msg = detailsWithStack(this.stack);
Expand All @@ -137,7 +135,7 @@ PluginError.prototype.toString = function() {
};

// Format the output message
function message(msg, thisArg) {
function message (msg, thisArg) {
var sig = colors.red(thisArg.name);
sig += ' in plugin ';
sig += '"' + colors.cyan(thisArg.plugin) + '"';
Expand All @@ -150,7 +148,7 @@ function message(msg, thisArg) {
* Set default options based on arguments.
*/

function setDefaults(plugin, message, opts) {
function setDefaults (plugin, message, opts) {
if (typeof plugin === 'object') {
return defaults(plugin);
}
Expand All @@ -176,10 +174,10 @@ function setDefaults(plugin, message, opts) {
* @return {Object}
*/

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

Expand Down
16 changes: 10 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
"index.js"
],
"scripts": {
"lint": "eslint . && jscs index.js test/",
"pretest": "npm run lint",
"lint:eslint": "eslint .",
"pretest": "npm-run-all --parallel lint:*",
"test": "mocha --async-only && npm run test-types",
"test-types": "tsc -p test/types",
"cover": "istanbul cover _mocha --report lcovonly",
Expand All @@ -33,14 +33,18 @@
"extend-shallow": "^3.0.2"
},
"devDependencies": {
"eslint": "^1.7.3",
"eslint-config-gulp": "^2.0.0",
"eslint": "^4.16.0",
"eslint-config-gulp": "github:BurtHarris/eslint-config-gulp#workitem_10",
"eslint-config-standard": "^11.0.0-beta.0",
"eslint-plugin-import": "^2.8.0",
"eslint-plugin-node": "^5.2.1",
"eslint-plugin-promise": "^3.6.0",
"eslint-plugin-standard": "^3.0.1",
"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",
"npm-run-all": "^4.1.2",
"typescript": "^2.6.2"
},
"keywords": [
Expand Down
4 changes: 3 additions & 1 deletion test/.eslintrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{
"extends": "gulp/test"
"env": {
"mocha": true
}
}
Loading