Skip to content

Instantly share code, notes, and snippets.

@caridy
Last active August 29, 2015 14:06
Show Gist options
  • Save caridy/ce355df399a222a85c93 to your computer and use it in GitHub Desktop.
Save caridy/ce355df399a222a85c93 to your computer and use it in GitHub Desktop.
/* 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