From 96ff9a201e98b5674f64aeb34f724761d3f600e7 Mon Sep 17 00:00:00 2001 From: John Gee Date: Sat, 1 Aug 2020 17:20:31 +1200 Subject: [PATCH 1/2] Improve basedir calculation to fix #1274 --- index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 5dacc8d88..3f120ce95 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 subcommand created. + if (!scriptPath && process.mainModule) { + scriptPath = process.mainModule.filename; + } let baseDir; try { From 17002ffb305638c4aa3ddee96cfb73166684295d Mon Sep 17 00:00:00 2001 From: John Gee Date: Sat, 1 Aug 2020 17:46:17 +1200 Subject: [PATCH 2/2] Improve comment --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 3f120ce95..98c8f8249 100644 --- a/index.js +++ b/index.js @@ -824,7 +824,7 @@ Read more on https://git.io/JJc0W`); // Want the entry script as the reference for command name and directory for searching for other files. let scriptPath = this._scriptPath; - // Fallback in case not set, due to how subcommand created. + // Fallback in case not set, due to how Command created or called. if (!scriptPath && process.mainModule) { scriptPath = process.mainModule.filename; }