Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure a default value is set for options.filename #81

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,10 @@ function resolve(id, opts, cb) {
// opts.packageFilter

opts = opts || {};

var base = path.dirname(opts.filename);

// NOTE: Starting with Node v6+ passing undefined to path.dirname results in a TypeError
// If opts.filename is undefined, use the filename that is being executed (e.g. node global: __filename)
var base = path.dirname(opts.filename || __filename);

if (opts.basedir) {
base = opts.basedir;
Expand Down