Skip to content

Commit

Permalink
check for require.main being defined in maindir
Browse files Browse the repository at this point in the history
  • Loading branch information
nrstott committed Oct 6, 2011
1 parent a3cd20c commit b9ef621
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/bogart.js
Expand Up @@ -618,6 +618,9 @@ exports.file = function(filePath, opts) {
* @returns {String} Directory of the script that was executed
*/
exports.maindir = function() {
if (typeof require.main === 'undefined') {
return __dirname;
}
return path.dirname(require.main.filename).replace("file://","");
};

Expand Down

0 comments on commit b9ef621

Please sign in to comment.