From a9ee01615445f4ef5de7f6136cfeec3dc6d8a0d3 Mon Sep 17 00:00:00 2001 From: nkoterba Date: Tue, 24 May 2016 19:54:29 -0400 Subject: [PATCH] Ensure a default value is set for options.filename Starting with Node v6+, path.dirname will **not** accept undefined inputs. Use the Node global variable `__filename` as a default value if `filename` is not passed in in the configuration object to node-browser-resolve-call. --- index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index aef07e2..632234d 100644 --- a/index.js +++ b/index.js @@ -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;