Last active
August 29, 2015 14:06
-
-
Save caridy/ce355df399a222a85c93 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* global HackToInferCallerFilename */ | |
'use strict'; | |
var REGEX_CALLER_FILENAME = /\(([^:]+)\:\d+\:\d+\)/g; | |
module.exports = function () { | |
var filename; | |
try { | |
HackToInferCallerFilename; | |
} catch (e) { | |
REGEX_CALLER_FILENAME.lastIndex = 80; // magic number to skip __filename reference | |
filename = REGEX_CALLER_FILENAME.exec(e.stack)[1]; | |
} | |
return filename; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment