From a71d592ee222de4c23215cf29d479b1687e324c5 Mon Sep 17 00:00:00 2001 From: John Gee Date: Sun, 2 Aug 2020 10:35:59 +1200 Subject: [PATCH] Improve basedir calculation to fix #1274 (#1322) * Improve basedir calculation to fix #1274 * Improve comment --- index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 538da1499..f02281101 100644 --- a/index.js +++ b/index.js @@ -823,7 +823,11 @@ Read more on https://git.io/JJc0W`); this._checkForMissingMandatoryOptions(); // Want the entry script as the reference for command name and directory for searching for other files. - const scriptPath = this._scriptPath; + let scriptPath = this._scriptPath; + // Fallback in case not set, due to how Command created or called. + if (!scriptPath && process.mainModule) { + scriptPath = process.mainModule.filename; + } let baseDir; try {