Skip to content

Commit a71d592

Browse files
authored
Improve basedir calculation to fix #1274 (#1322)
* Improve basedir calculation to fix #1274 * Improve comment
1 parent c7f5f78 commit a71d592

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

index.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,11 @@ Read more on https://git.io/JJc0W`);
823823
this._checkForMissingMandatoryOptions();
824824

825825
// Want the entry script as the reference for command name and directory for searching for other files.
826-
const scriptPath = this._scriptPath;
826+
let scriptPath = this._scriptPath;
827+
// Fallback in case not set, due to how Command created or called.
828+
if (!scriptPath && process.mainModule) {
829+
scriptPath = process.mainModule.filename;
830+
}
827831

828832
let baseDir;
829833
try {

0 commit comments

Comments
 (0)