Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Commit

Permalink
Check that require.main.filename is defined (#233)
Browse files Browse the repository at this point in the history
  • Loading branch information
LewisJEllis committed Nov 18, 2016
1 parent ce62715 commit b84b88c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function getFunction(line) {
}
}

var main_module = (require.main && path.dirname(require.main.filename) || process.cwd()) + '/';
var main_module = (require.main && require.main.filename && path.dirname(require.main.filename) || process.cwd()) + '/';

function getModule(filename, base) {
if (!base) base = main_module;
Expand Down Expand Up @@ -179,4 +179,4 @@ function parseStack(err, cb) {

// expose basically for testing because I don't know what I'm doing
module.exports.parseStack = parseStack;
module.exports.getModule = getModule;
module.exports.getModule = getModule;

1 comment on commit b84b88c

@benvinegar
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just pointing out that if require.main.filename is null, we won't fall back to process.cwd (not that we were before – it just blew up).

Please sign in to comment.