// Inspired by http://stackoverflow.com/questions/13227489
// If you call this in a another function it returns you the file from
// which this function was called from. (Inspects the v8 stack trace)

module.exports = getCallerFile;
function getCallerFile() {
    var oldPrepareStackTrace = Error.prepareStackTrace;
    Error.prepareStackTrace = function (err, stack) {return stack;};
    var stack = new Error().stack;
    Error.prepareStackTrace = oldPrepareStackTrace;
    return stack[2] ? stack[2].getFileName() : undefined;
}
@@ -1,82 +1,25 @@
 // 
-Inspired by http://stackoverflow.com/questions/13227489%0A// If you call this
+Call this function
  in 
@@ -41,22 +41,19 @@
 ion 
-it returns y
+to find 
 ou
+t
  the
@@ -74,18 +74,18 @@
 which th
-is
+at
  functio
@@ -132,16 +132,78 @@
 k trace)
+%0A//%0A// Inspired by http://stackoverflow.com/questions/13227489
 %0A%0Amodule
@@ -364,16 +364,17 @@
 stack) %7B
+ 
 return s
@@ -378,16 +378,17 @@
 n stack;
+ 
 %7D;%0A    v
@@ -464,24 +464,161 @@
 eStackTrace;
+%0A%0A    // stack%5B0%5D holds this file%0A    // stack%5B1%5D holds where this function was called%0A    // stack%5B2%5D holds the file we're interested in
 %0A    return 

Comment getCallerFile