console/patches/@oclif__core@4.0.6.patch

27 lines
1.1 KiB
Diff
Raw Normal View History

diff --git a/lib/module-loader.js b/lib/module-loader.js
index 6162032e60f1e44ecfa19525ee07eecee1186208..52e99df36c28ad3603ab4e669f0c30181e6b1335 100644
--- a/lib/module-loader.js
+++ b/lib/module-loader.js
@@ -155,7 +155,20 @@ async function resolvePath(config, modulePath) {
let isESM;
let filePath;
try {
- filePath = require.resolve(modulePath);
+ try {
+ // We wrap it with try/catch and fallback to custom path if it fails to make it compatible with Hive.
+ // Due to some weird behavior in tsup/esbuild, it fails to resolve the path to the module.
+ filePath = require.resolve(modulePath);
+ } catch (error) {
+ const customPath = process.env.OCLIF_CLI_CUSTOM_PATH;
+ if (typeof customPath !== "string") {
+ throw error;
+ }
+ modulePath = modulePath.replace('/src/', '/dist/').replace('\\src\\', '\\dist\\');
+ filePath = require.resolve(
+ path.resolve(customPath, modulePath) + ".js"
+ );
+ }
isESM = isPathModule(filePath);
}
catch {