[Pkg-javascript-commits] [node-clean-stack] 01/03: Import Upstream version 1.1.1

Abhishek Lolage abhisheklolage-guest at moszumanska.debian.org
Sat Feb 11 18:41:13 UTC 2017


This is an automated email from the git hooks/post-receive script.

abhisheklolage-guest pushed a commit to branch master
in repository node-clean-stack.

commit 0f5f9784194c08784fbaab16b94765e4f80b2d75
Author: Abhishek Lolage <abhisheklolage at gmail.com>
Date:   Wed Feb 8 19:23:01 2017 +0000

    Import Upstream version 1.1.1
---
 .editorconfig  | 12 ++++++++++
 .gitattributes |  1 +
 .gitignore     |  1 +
 .travis.yml    |  4 ++++
 index.js       | 19 ++++++++++++++++
 license        | 21 ++++++++++++++++++
 package.json   | 33 +++++++++++++++++++++++++++
 readme.md      | 48 ++++++++++++++++++++++++++++++++++++++++
 test.js        | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 9 files changed, 209 insertions(+)

diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..98a761d
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,12 @@
+root = true
+
+[*]
+indent_style = tab
+end_of_line = lf
+charset = utf-8
+trim_trailing_whitespace = true
+insert_final_newline = true
+
+[{package.json,*.yml}]
+indent_style = space
+indent_size = 2
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..176a458
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1 @@
+* text=auto
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..3c3629e
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+node_modules
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..97519af
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,4 @@
+language: node_js
+node_js:
+  - '6'
+  - '4'
diff --git a/index.js b/index.js
new file mode 100644
index 0000000..0e2ee7a
--- /dev/null
+++ b/index.js
@@ -0,0 +1,19 @@
+'use strict';
+
+const extractPathRegex = /\s+at.*(?:\(|\s)(.*)\)?/;
+const pathRegex = /^(?:(?:(?:node|(?:internal\/[\w/]*|.*node_modules\/babel-polyfill\/.*)?\w+)\.js:\d+:\d+)|native)/;
+
+module.exports = stack => {
+	return stack.replace(/\\/g, '/')
+		.split('\n')
+		.filter(x => {
+			const pathMatches = x.match(extractPathRegex);
+			if (pathMatches === null || !pathMatches[1]) {
+				return true;
+			}
+
+			return !pathRegex.test(pathMatches[1]);
+		})
+		.filter(x => x.trim() !== '')
+		.join('\n');
+};
diff --git a/license b/license
new file mode 100644
index 0000000..654d0bf
--- /dev/null
+++ b/license
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) Sindre Sorhus <sindresorhus at gmail.com> (sindresorhus.com)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..c9a3cef
--- /dev/null
+++ b/package.json
@@ -0,0 +1,33 @@
+{
+  "name": "clean-stack",
+  "version": "1.1.1",
+  "description": "Clean up error stack traces",
+  "license": "MIT",
+  "repository": "sindresorhus/clean-stack",
+  "author": {
+    "name": "Sindre Sorhus",
+    "email": "sindresorhus at gmail.com",
+    "url": "sindresorhus.com"
+  },
+  "engines": {
+    "node": ">=4"
+  },
+  "scripts": {
+    "test": "xo && ava"
+  },
+  "files": [
+    "index.js"
+  ],
+  "keywords": [
+    "clean",
+    "stack",
+    "trace",
+    "traces",
+    "error",
+    "err"
+  ],
+  "devDependencies": {
+    "ava": "*",
+    "xo": "*"
+  }
+}
diff --git a/readme.md b/readme.md
new file mode 100644
index 0000000..c6cf2a1
--- /dev/null
+++ b/readme.md
@@ -0,0 +1,48 @@
+# clean-stack [![Build Status](https://travis-ci.org/sindresorhus/clean-stack.svg?branch=master)](https://travis-ci.org/sindresorhus/clean-stack)
+
+> Clean up error stack traces
+
+Removes the mostly unhelpful internal Node.js entries.
+
+
+## Install
+
+```
+$ npm install --save clean-stack
+```
+
+
+## Usage
+
+```js
+const cleanStack = require('clean-stack');
+const error = new Error('Missing unicorn');
+
+console.log(error.stack);
+/*
+Error: Missing unicorn
+    at Object.<anonymous> (/Users/sindresorhus/dev/clean-stack/unicorn.js:2:15)
+    at Module._compile (module.js:409:26)
+    at Object.Module._extensions..js (module.js:416:10)
+    at Module.load (module.js:343:32)
+    at Function.Module._load (module.js:300:12)
+    at Function.Module.runMain (module.js:441:10)
+    at startup (node.js:139:18)
+*/
+
+console.log(cleanStack(error.stack));
+/*
+Error: Missing unicorn
+    at Object.<anonymous> (/Users/sindresorhus/dev/clean-stack/unicorn.js:2:15)
+*/
+```
+
+
+## Related
+
+Check out [stack-utils](https://github.com/tapjs/stack-utils) if you want something more.
+
+
+## License
+
+MIT © [Sindre Sorhus](https://sindresorhus.com)
diff --git a/test.js b/test.js
new file mode 100644
index 0000000..a360178
--- /dev/null
+++ b/test.js
@@ -0,0 +1,70 @@
+import test from 'ava';
+import m from './';
+
+test('default', t => {
+	const pre = 'Error: foo\n    at Test.fn (/Users/sindresorhus/dev/clean-stack/test.js:6:15)';
+	const stack = `${pre}\n
+    at handleMessage (internal/child_process.js:695:10)\n
+    at Pipe.channel.onread (internal/child_process.js:440:11)\n
+    at process.emit (events.js:172:7)`;
+	t.is(m(stack), pre);
+});
+
+test('default #2', t => {
+	const pre = 'Error: foo\n    at Object.<anonymous> (/Users/sindresorhus/dev/clean-stack/unicorn.js:4:7)';
+	const stack = `${pre}\n
+    at Module._compile (module.js:409:26)
+    at Object.Module._extensions..js (module.js:416:10)
+    at Module.load (module.js:343:32)
+    at Function.Module._load (module.js:300:12)
+    at Function.Module.runMain (module.js:441:10)
+    at startup (node.js:139:18)`;
+	t.is(m(stack), pre);
+});
+
+test('directly executed node script', t => {
+	const pre = 'Error: foo\n    at Object.<anonymous> (/Users/sindresorhus/dev/clean-stack/unicorn.js:4:7)';
+	const stack = `${pre}\n
+    at Module._compile (module.js:409:26)
+    at Object.Module._extensions..js (module.js:416:10)
+    at Module.load (module.js:343:32)
+    at Function.Module._load (module.js:300:12)
+    at Function.Module.runMain (module.js:441:10)
+    at startup (node.js:139:18)
+    at node.js:968:3`;
+	t.is(m(stack), pre);
+});
+
+test('internal child_process', t => {
+	const pre = 'Error: foo\n    at Object.<anonymous> (/Users/sindresorhus/dev/clean-stack/unicorn.js:4:7)';
+	const stack = `${pre}\n
+    at Module._compile (module.js:409:26)
+    at Object.Module._extensions..js (module.js:416:10)
+    at internal/child_process.js:696:12`;
+	t.is(m(stack), pre);
+});
+
+test('internal next_tick', t => {
+	const pre = 'Error: foo\n    at Object.<anonymous> (/Users/sindresorhus/dev/clean-stack/unicorn.js:4:7)';
+	const stack = `${pre}\n
+    at _combinedTickCallback (internal/process/next_tick.js:67:7)
+    at process._tickCallback (internal/process/next_tick.js:98:9)`;
+	t.is(m(stack), pre);
+});
+
+test('babel-polyfill', t => {
+	const pre = 'Error: foo\n    at Object.<anonymous> (/Users/sindresorhus/dev/clean-stack/unicorn.js:4:7)';
+	const stack = `${pre}\n
+    at run (/Users/sindresorhus/dev/clean-stack/node_modules/babel-polyfill/node_modules/core-js/modules/es6.promise.js:87:22)
+    at /Users/sindresorhus/dev/clean-stack/node_modules/babel-polyfill/node_modules/core-js/modules/es6.promise.js:100:28`;
+	t.is(m(stack), pre);
+});
+
+test('work on Windows', t => {
+	const expected = 'Error: foo\n    at Test.fn (/Users/sindresorhus/dev/clean-stack/test.js:6:15)';
+	const stack = `Error: foo\n    at Test.fn (\\Users\\sindresorhus\\dev\\clean-stack\\test.js:6:15)\n
+    at handleMessage (internal\\child_process.js:695:10)\n
+    at Pipe.channel.onread (internal\\child_process.js:440:11)\n
+    at process.emit (events.js:172:7)`;
+	t.is(m(stack), expected);
+});

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-clean-stack.git



More information about the Pkg-javascript-commits mailing list