[Pkg-javascript-commits] [node-stack-utils] 23/67: simplify setting the filename

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 d9bed8938c7aad5d4476d5a07088e3acbda15691
Author: James Talmage <james at talmage.io>
Date:   Fri Jan 8 16:01:54 2016 -0500

    simplify setting the filename
---
 index.js | 27 ++++++++++++---------------
 1 file changed, 12 insertions(+), 15 deletions(-)

diff --git a/index.js b/index.js
index c1e8ce1..2caf0d5 100644
--- a/index.js
+++ b/index.js
@@ -124,14 +124,7 @@ StackUtils.prototype.at = function at(fn) {
 		column: site.getColumnNumber()
 	};
 
-	var file = site.getFileName();
-	if (file) {
-		file = file.replace(/\\/g, '/');
-		if (file.indexOf(this._cwd + '/') === 0) {
-			file = file.substr(this._cwd.length + 1);
-		}
-		res.file = file;
-	}
+	this._setFile(res, site.getFileName());
 
 	if (site.isConstructor()) {
 		res.constructor = true;
@@ -169,6 +162,16 @@ StackUtils.prototype.at = function at(fn) {
 	return res;
 };
 
+StackUtils.prototype._setFile = function (result, filename) {
+	if (filename) {
+		filename = filename.replace(/\\/g, '/');
+		if ((filename.indexOf(this._cwd + '/') === 0)) {
+			filename = filename.substr(this._cwd.length + 1);
+		}
+		result.file = filename;
+	}
+};
+
 var re = new RegExp(
 	'^' +
 		// Sometimes we strip out the '    at' because it's noisy
@@ -219,13 +222,7 @@ StackUtils.prototype.parseLine = function parseLine(line) {
 		res.column = Number(col);
 	}
 
-	if (file) {
-		file = file.replace(/\\/g, '/');
-		if ((file.indexOf(this._cwd + '/') === 0)) {
-			file = file.substr(this._cwd.length + 1);
-		}
-		res.file = file;
-	}
+	this._setFile(res, file);
 
 	if (ctor) {
 		res.constructor = true;

-- 
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