[Pkg-javascript-commits] [node-stack-utils] 26/67: Normalize to unix style paths before filtering out "internals".
Bastien Roucariès
rouca at moszumanska.debian.org
Thu Sep 7 09:53:03 UTC 2017
This is an automated email from the git hooks/post-receive script.
rouca pushed a commit to branch master
in repository node-stack-utils.
commit df98523cffff683d80401b88f6ad9fbce1e37d9b
Author: James Talmage <james at talmage.io>
Date: Wed Jan 13 19:53:00 2016 -0500
Normalize to unix style paths before filtering out "internals".
This makes it a little easier to write regular expressions for internals by normalizing the array before applying the filter. This means your regular expression only needs to deal with forward slash separators
Fixes #9
---
index.js | 8 +++-----
test/long-stack-traces.js | 12 ++++++------
test/test.js | 2 +-
3 files changed, 10 insertions(+), 12 deletions(-)
diff --git a/index.js b/index.js
index f97cd87..5551c72 100644
--- a/index.js
+++ b/index.js
@@ -38,8 +38,8 @@ StackUtils.prototype.clean = function (stack) {
var lastNonAtLine = null;
var result = [];
- stack.forEach(function (st1) {
- var st = st1;
+ stack.forEach(function (st) {
+ st = st.replace(/\\/g, '/');
var isInternal = this._internals.some(function (internal) {
return internal.test(st);
});
@@ -59,9 +59,7 @@ StackUtils.prototype.clean = function (stack) {
}
}
- st = st
- .replace(/\\/g, '/')
- .replace(this._cwd + '/', '');
+ st = st.replace(this._cwd + '/', '');
if (st) {
if (isAtLine) {
diff --git a/test/long-stack-traces.js b/test/long-stack-traces.js
index 5b62d11..3b432f8 100644
--- a/test/long-stack-traces.js
+++ b/test/long-stack-traces.js
@@ -8,13 +8,13 @@ import {join, fixtureDir} from './_utils';
function internals() {
return StackUtils.nodeInternals().concat([
- /[\\\/]long-stack-traces\.js:[0-9]+:[0-9]+\)?$/,
- /[\\\/]internal-error\.js:[0-9]+:[0-9]+\)?$/,
- /[\\\/]internal-then\.js:[0-9]+:[0-9]+\)?$/,
- /[\\\/]node_modules[\\\/]/,
+ /\/long-stack-traces\.js:[0-9]+:[0-9]+\)?$/,
+ /\/internal-error\.js:[0-9]+:[0-9]+\)?$/,
+ /\/internal-then\.js:[0-9]+:[0-9]+\)?$/,
+ /\/node_modules\//,
// TODO: Should any of these be default internals?
- /[\\\/]\.node-spawn-wrap-\w+-\w+[\\\/]node:[0-9]+:[0-9]+\)?$/,
- /internal[\\\/]module\.js:[0-9]+:[0-9]+\)?$/,
+ /\/\.node-spawn-wrap-\w+-\w+\/node:[0-9]+:[0-9]+\)?$/,
+ /internal\/module\.js:[0-9]+:[0-9]+\)?$/,
/node\.js:[0-9]+:[0-9]+\)?$/
]);
}
diff --git a/test/test.js b/test/test.js
index 9a764e4..2b54458 100644
--- a/test/test.js
+++ b/test/test.js
@@ -327,6 +327,6 @@ function internalStack() {
function internals() {
return StackUtils.nodeInternals().concat([
/test\.js:[0-9]+:[0-9]+\)?$/,
- /[\\\/]node_modules[\\\/]/
+ /\/node_modules\//
]);
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-stack-utils.git
More information about the Pkg-javascript-commits
mailing list