update
This commit is contained in:
+88
-40
@@ -1,9 +1,9 @@
|
||||
// Generated by CoffeeScript 1.8.0
|
||||
var ParsedError, PrettyError, RenderKid, array, defaultStyle, instance, nodePaths, object, prop, _fn, _i, _len, _ref, _ref1,
|
||||
var ParsedError, PrettyError, RenderKid, arrayUtils, defaultStyle, instance, isPlainObject, merge, nodePaths, prop, _fn, _i, _len, _ref,
|
||||
__slice = [].slice,
|
||||
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
|
||||
|
||||
_ref = require('utila'), object = _ref.object, array = _ref.array;
|
||||
isPlainObject = require('lodash/isPlainObject');
|
||||
|
||||
defaultStyle = require('./defaultStyle');
|
||||
|
||||
@@ -13,6 +13,54 @@ nodePaths = require('./nodePaths');
|
||||
|
||||
RenderKid = require('renderkid');
|
||||
|
||||
merge = require('lodash/merge');
|
||||
|
||||
arrayUtils = {
|
||||
pluckByCallback: function(a, cb) {
|
||||
var index, removed, value, _i, _len;
|
||||
if (a.length < 1) {
|
||||
return a;
|
||||
}
|
||||
removed = 0;
|
||||
for (index = _i = 0, _len = a.length; _i < _len; index = ++_i) {
|
||||
value = a[index];
|
||||
if (cb(value, index)) {
|
||||
removed++;
|
||||
continue;
|
||||
}
|
||||
if (removed !== 0) {
|
||||
a[index - removed] = a[index];
|
||||
}
|
||||
}
|
||||
if (removed > 0) {
|
||||
a.length = a.length - removed;
|
||||
}
|
||||
return a;
|
||||
},
|
||||
pluckOneItem: function(a, item) {
|
||||
var index, reached, value, _i, _len;
|
||||
if (a.length < 1) {
|
||||
return a;
|
||||
}
|
||||
reached = false;
|
||||
for (index = _i = 0, _len = a.length; _i < _len; index = ++_i) {
|
||||
value = a[index];
|
||||
if (!reached) {
|
||||
if (value === item) {
|
||||
reached = true;
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
a[index - 1] = a[index];
|
||||
}
|
||||
}
|
||||
if (reached) {
|
||||
a.length = a.length - 1;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
};
|
||||
|
||||
instance = null;
|
||||
|
||||
module.exports = PrettyError = (function() {
|
||||
@@ -89,7 +137,7 @@ module.exports = PrettyError = (function() {
|
||||
};
|
||||
|
||||
PrettyError.prototype.config = function(c) {
|
||||
var alias, path, _ref1;
|
||||
var alias, path, _ref;
|
||||
if (c.skipPackages != null) {
|
||||
if (c.skipPackages === false) {
|
||||
this.unskipAllPackages();
|
||||
@@ -134,10 +182,10 @@ module.exports = PrettyError = (function() {
|
||||
}
|
||||
}
|
||||
if (c.aliases != null) {
|
||||
if (object.isBareObject(c.aliases)) {
|
||||
_ref1 = c.aliases;
|
||||
for (path in _ref1) {
|
||||
alias = _ref1[path];
|
||||
if (isPlainObject(c.aliases)) {
|
||||
_ref = c.aliases;
|
||||
for (path in _ref) {
|
||||
alias = _ref[path];
|
||||
this.alias(path, alias);
|
||||
}
|
||||
} else if (c.aliases === false) {
|
||||
@@ -172,7 +220,7 @@ module.exports = PrettyError = (function() {
|
||||
packages = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
||||
for (_i = 0, _len = packages.length; _i < _len; _i++) {
|
||||
pkg = packages[_i];
|
||||
array.pluckOneItem(this._packagesToSkip, pkg);
|
||||
arrayUtils.pluckOneItem(this._packagesToSkip, pkg);
|
||||
}
|
||||
return this;
|
||||
};
|
||||
@@ -197,7 +245,7 @@ module.exports = PrettyError = (function() {
|
||||
paths = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
||||
for (_i = 0, _len = paths.length; _i < _len; _i++) {
|
||||
path = paths[_i];
|
||||
array.pluckOneItem(this._pathsToSkip, path);
|
||||
arrayUtils.pluckOneItem(this._pathsToSkip, path);
|
||||
}
|
||||
return this;
|
||||
};
|
||||
@@ -222,7 +270,7 @@ module.exports = PrettyError = (function() {
|
||||
callbacks = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
||||
for (_i = 0, _len = callbacks.length; _i < _len; _i++) {
|
||||
cb = callbacks[_i];
|
||||
array.pluckOneItem(this._skipCallbacks, cb);
|
||||
arrayUtils.pluckOneItem(this._skipCallbacks, cb);
|
||||
}
|
||||
return this;
|
||||
};
|
||||
@@ -255,7 +303,7 @@ module.exports = PrettyError = (function() {
|
||||
callbacks = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
||||
for (_i = 0, _len = callbacks.length; _i < _len; _i++) {
|
||||
cb = callbacks[_i];
|
||||
array.pluckOneItem(this._filterCallbacks, cb);
|
||||
arrayUtils.pluckOneItem(this._filterCallbacks, cb);
|
||||
}
|
||||
return this;
|
||||
};
|
||||
@@ -280,7 +328,7 @@ module.exports = PrettyError = (function() {
|
||||
callbacks = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
||||
for (_i = 0, _len = callbacks.length; _i < _len; _i++) {
|
||||
cb = callbacks[_i];
|
||||
array.pluckOneItem(this._parsedErrorFilters, cb);
|
||||
arrayUtils.pluckOneItem(this._parsedErrorFilters, cb);
|
||||
}
|
||||
return this;
|
||||
};
|
||||
@@ -310,7 +358,7 @@ module.exports = PrettyError = (function() {
|
||||
};
|
||||
|
||||
PrettyError.prototype.removeAlias = function(stringOrRx) {
|
||||
array.pluckByCallback(this._aliases, function(pair) {
|
||||
arrayUtils.pluckByCallback(this._aliases, function(pair) {
|
||||
return pair.stringOrRx === stringOrRx;
|
||||
});
|
||||
return this;
|
||||
@@ -326,7 +374,7 @@ module.exports = PrettyError = (function() {
|
||||
};
|
||||
|
||||
PrettyError.prototype.appendStyle = function(toAppend) {
|
||||
object.appendOnto(this._style, toAppend);
|
||||
merge(this._style, toAppend);
|
||||
this._renderer.style(toAppend);
|
||||
return this;
|
||||
};
|
||||
@@ -352,7 +400,7 @@ module.exports = PrettyError = (function() {
|
||||
};
|
||||
|
||||
PrettyError.prototype.getObject = function(e) {
|
||||
var count, header, i, item, obj, traceItems, _i, _len, _ref1;
|
||||
var count, header, i, item, obj, traceItems, _i, _len, _ref;
|
||||
if (!(e instanceof ParsedError)) {
|
||||
e = new ParsedError(e);
|
||||
}
|
||||
@@ -372,9 +420,9 @@ module.exports = PrettyError = (function() {
|
||||
};
|
||||
traceItems = [];
|
||||
count = -1;
|
||||
_ref1 = e.trace;
|
||||
for (i = _i = 0, _len = _ref1.length; _i < _len; i = ++_i) {
|
||||
item = _ref1[i];
|
||||
_ref = e.trace;
|
||||
for (i = _i = 0, _len = _ref.length; _i < _len; i = ++_i) {
|
||||
item = _ref[i];
|
||||
if (item == null) {
|
||||
continue;
|
||||
}
|
||||
@@ -439,49 +487,49 @@ module.exports = PrettyError = (function() {
|
||||
};
|
||||
|
||||
PrettyError.prototype._skipOrFilter = function(item, itemNumber) {
|
||||
var cb, modName, pair, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref1, _ref2, _ref3, _ref4, _ref5, _ref6;
|
||||
var cb, modName, pair, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref, _ref1, _ref2, _ref3, _ref4, _ref5;
|
||||
if (typeof item === 'object') {
|
||||
if (_ref1 = item.modName, __indexOf.call(this._packagesToSkip, _ref1) >= 0) {
|
||||
if (_ref = item.modName, __indexOf.call(this._packagesToSkip, _ref) >= 0) {
|
||||
return true;
|
||||
}
|
||||
if (_ref2 = item.path, __indexOf.call(this._pathsToSkip, _ref2) >= 0) {
|
||||
if (_ref1 = item.path, __indexOf.call(this._pathsToSkip, _ref1) >= 0) {
|
||||
return true;
|
||||
}
|
||||
_ref3 = item.packages;
|
||||
for (_i = 0, _len = _ref3.length; _i < _len; _i++) {
|
||||
modName = _ref3[_i];
|
||||
_ref2 = item.packages;
|
||||
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
|
||||
modName = _ref2[_i];
|
||||
if (__indexOf.call(this._packagesToSkip, modName) >= 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (typeof item.shortenedAddr === 'string') {
|
||||
_ref4 = this._aliases;
|
||||
for (_j = 0, _len1 = _ref4.length; _j < _len1; _j++) {
|
||||
pair = _ref4[_j];
|
||||
_ref3 = this._aliases;
|
||||
for (_j = 0, _len1 = _ref3.length; _j < _len1; _j++) {
|
||||
pair = _ref3[_j];
|
||||
item.shortenedAddr = item.shortenedAddr.replace(pair.stringOrRx, pair.alias);
|
||||
}
|
||||
}
|
||||
}
|
||||
_ref5 = this._skipCallbacks;
|
||||
for (_k = 0, _len2 = _ref5.length; _k < _len2; _k++) {
|
||||
cb = _ref5[_k];
|
||||
_ref4 = this._skipCallbacks;
|
||||
for (_k = 0, _len2 = _ref4.length; _k < _len2; _k++) {
|
||||
cb = _ref4[_k];
|
||||
if (cb(item, itemNumber) === true) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
_ref6 = this._filterCallbacks;
|
||||
for (_l = 0, _len3 = _ref6.length; _l < _len3; _l++) {
|
||||
cb = _ref6[_l];
|
||||
_ref5 = this._filterCallbacks;
|
||||
for (_l = 0, _len3 = _ref5.length; _l < _len3; _l++) {
|
||||
cb = _ref5[_l];
|
||||
cb(item, itemNumber);
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
PrettyError.prototype._applyParsedErrorFiltersOn = function(error) {
|
||||
var cb, _i, _len, _ref1;
|
||||
_ref1 = this._parsedErrorFilters;
|
||||
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
|
||||
cb = _ref1[_i];
|
||||
var cb, _i, _len, _ref;
|
||||
_ref = this._parsedErrorFilters;
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
cb = _ref[_i];
|
||||
cb(error);
|
||||
}
|
||||
};
|
||||
@@ -490,7 +538,7 @@ module.exports = PrettyError = (function() {
|
||||
|
||||
})();
|
||||
|
||||
_ref1 = ['renderer', 'style'];
|
||||
_ref = ['renderer', 'style'];
|
||||
_fn = function() {
|
||||
var methodName;
|
||||
methodName = '_get' + prop[0].toUpperCase() + prop.substr(1, prop.length);
|
||||
@@ -498,7 +546,7 @@ _fn = function() {
|
||||
return this[methodName]();
|
||||
});
|
||||
};
|
||||
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
|
||||
prop = _ref1[_i];
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
prop = _ref[_i];
|
||||
_fn();
|
||||
}
|
||||
|
||||
+14
-14
@@ -1,32 +1,32 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"pretty-error@2.1.1",
|
||||
"/mnt/Foxconn/Digitalent/Deverloper/liff-push_2series"
|
||||
"pretty-error@2.1.2",
|
||||
"/home/node/nuxt"
|
||||
]
|
||||
],
|
||||
"_from": "pretty-error@2.1.1",
|
||||
"_id": "pretty-error@2.1.1",
|
||||
"_from": "pretty-error@2.1.2",
|
||||
"_id": "pretty-error@2.1.2",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-X0+HyPkeWuPzuoerTPXgOxoX8aM=",
|
||||
"_integrity": "sha512-EY5oDzmsX5wvuynAByrmY0P0hcp+QpnAKbJng2A2MPjVKXCxrDSUkzghVJ4ZGPIv+JC4gX8fPUWscC0RtjsWGw==",
|
||||
"_location": "/pretty-error",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "pretty-error@2.1.1",
|
||||
"raw": "pretty-error@2.1.2",
|
||||
"name": "pretty-error",
|
||||
"escapedName": "pretty-error",
|
||||
"rawSpec": "2.1.1",
|
||||
"rawSpec": "2.1.2",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "2.1.1"
|
||||
"fetchSpec": "2.1.2"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/html-webpack-plugin"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/pretty-error/-/pretty-error-2.1.1.tgz",
|
||||
"_spec": "2.1.1",
|
||||
"_where": "/mnt/Foxconn/Digitalent/Deverloper/liff-push_2series",
|
||||
"_resolved": "https://registry.npmjs.org/pretty-error/-/pretty-error-2.1.2.tgz",
|
||||
"_spec": "2.1.2",
|
||||
"_where": "/home/node/nuxt",
|
||||
"author": {
|
||||
"name": "Aria Minaei"
|
||||
},
|
||||
@@ -34,8 +34,8 @@
|
||||
"url": "https://github.com/AriaMinaei/pretty-error/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"renderkid": "^2.0.1",
|
||||
"utila": "~0.4"
|
||||
"lodash": "^4.17.20",
|
||||
"renderkid": "^2.0.4"
|
||||
},
|
||||
"description": "See nodejs errors with less clutter",
|
||||
"devDependencies": {
|
||||
@@ -74,5 +74,5 @@
|
||||
"winwatch": "start/b npm run compile:watch & npm run test:watch"
|
||||
},
|
||||
"typings": "index.d.ts",
|
||||
"version": "2.1.1"
|
||||
"version": "2.1.2"
|
||||
}
|
||||
|
||||
+43
-9
@@ -1,8 +1,42 @@
|
||||
{object, array} = require 'utila'
|
||||
isPlainObject = require 'lodash/isPlainObject'
|
||||
defaultStyle = require './defaultStyle'
|
||||
ParsedError = require './ParsedError'
|
||||
nodePaths = require './nodePaths'
|
||||
RenderKid = require 'renderkid'
|
||||
merge = require 'lodash/merge'
|
||||
|
||||
arrayUtils =
|
||||
pluckByCallback: (a, cb) ->
|
||||
return a if a.length < 1
|
||||
removed = 0
|
||||
|
||||
for value, index in a
|
||||
if cb value, index
|
||||
removed++
|
||||
continue
|
||||
|
||||
if removed isnt 0
|
||||
a[index - removed] = a[index]
|
||||
|
||||
if removed > 0
|
||||
a.length = a.length - removed
|
||||
|
||||
a
|
||||
|
||||
pluckOneItem: (a, item) ->
|
||||
return a if a.length < 1
|
||||
reached = no
|
||||
|
||||
for value, index in a
|
||||
if not reached
|
||||
if value is item
|
||||
reached = yes
|
||||
continue
|
||||
else
|
||||
a[index - 1] = a[index]
|
||||
|
||||
a.length = a.length - 1 if reached
|
||||
a
|
||||
|
||||
instance = null
|
||||
|
||||
@@ -100,7 +134,7 @@ module.exports = class PrettyError
|
||||
@filterParsedError.apply @, c.parsedErrorFilters
|
||||
|
||||
if c.aliases?
|
||||
if object.isBareObject c.aliases
|
||||
if isPlainObject c.aliases
|
||||
@alias path, alias for path, alias of c.aliases
|
||||
else if c.aliases is no
|
||||
@removeAllAliases()
|
||||
@@ -120,7 +154,7 @@ module.exports = class PrettyError
|
||||
@
|
||||
|
||||
unskipPackage: (packages...) ->
|
||||
array.pluckOneItem(@_packagesToSkip, pkg) for pkg in packages
|
||||
arrayUtils.pluckOneItem(@_packagesToSkip, pkg) for pkg in packages
|
||||
@
|
||||
|
||||
unskipAllPackages: ->
|
||||
@@ -132,7 +166,7 @@ module.exports = class PrettyError
|
||||
@
|
||||
|
||||
unskipPath: (paths...) ->
|
||||
array.pluckOneItem(@_pathsToSkip, path) for path in paths
|
||||
arrayUtils.pluckOneItem(@_pathsToSkip, path) for path in paths
|
||||
@
|
||||
|
||||
unskipAllPaths: ->
|
||||
@@ -144,7 +178,7 @@ module.exports = class PrettyError
|
||||
@
|
||||
|
||||
unskip: (callbacks...) ->
|
||||
array.pluckOneItem(@_skipCallbacks, cb) for cb in callbacks
|
||||
arrayUtils.pluckOneItem(@_skipCallbacks, cb) for cb in callbacks
|
||||
@
|
||||
|
||||
unskipAll: ->
|
||||
@@ -162,7 +196,7 @@ module.exports = class PrettyError
|
||||
@
|
||||
|
||||
removeFilter: (callbacks...) ->
|
||||
array.pluckOneItem(@_filterCallbacks, cb) for cb in callbacks
|
||||
arrayUtils.pluckOneItem(@_filterCallbacks, cb) for cb in callbacks
|
||||
@
|
||||
|
||||
removeAllFilters: ->
|
||||
@@ -174,7 +208,7 @@ module.exports = class PrettyError
|
||||
@
|
||||
|
||||
removeParsedErrorFilter: (callbacks...) ->
|
||||
array.pluckOneItem(@_parsedErrorFilters, cb) for cb in callbacks
|
||||
arrayUtils.pluckOneItem(@_parsedErrorFilters, cb) for cb in callbacks
|
||||
@
|
||||
|
||||
removeAllParsedErrorFilters: ->
|
||||
@@ -191,7 +225,7 @@ module.exports = class PrettyError
|
||||
@
|
||||
|
||||
removeAlias: (stringOrRx) ->
|
||||
array.pluckByCallback @_aliases, (pair) ->
|
||||
arrayUtils.pluckByCallback @_aliases, (pair) ->
|
||||
pair.stringOrRx is stringOrRx
|
||||
|
||||
@
|
||||
@@ -204,7 +238,7 @@ module.exports = class PrettyError
|
||||
@_style
|
||||
|
||||
appendStyle: (toAppend) ->
|
||||
object.appendOnto @_style, toAppend
|
||||
merge @_style, toAppend
|
||||
@_renderer.style toAppend
|
||||
@
|
||||
|
||||
|
||||
Reference in New Issue
Block a user