Skip to content

Commit

Permalink
fix: consider the cli install directory when resolving plugins (#1838)
Browse files Browse the repository at this point in the history
  • Loading branch information
volodymyr-rutskyi authored Jan 7, 2025
1 parent 3365bfb commit 91c2033
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .changeset/tender-forks-argue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@redocly/openapi-core": patch
"@redocly/cli": patch
---

Fixed an issue where running the `preview` command failed because one of its dependencies could not be resolved.
The issue occurred when Realm was not installed in the `node_modules` of the project.
9 changes: 8 additions & 1 deletion packages/core/src/config/config-resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,14 @@ export async function resolvePlugins(
const absolutePluginPath = existsSync(maybeAbsolutePluginPath)
? maybeAbsolutePluginPath
: // For plugins imported from packages specifically
require.resolve(plugin, { paths: [configDir] });
require.resolve(plugin, {
paths: [
// Plugins imported from the node_modules in the project directory
configDir,
// Plugins imported from the node_modules in the package install directory (for example, npx cache directory)
__dirname,
],
});

if (!pluginsCache.has(absolutePluginPath)) {
let requiredPlugin: ImportedPlugin | undefined;
Expand Down

1 comment on commit 91c2033

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements 78.61% 5046/6419
🟡 Branches 67.24% 2055/3056
🟡 Functions 73.13% 833/1139
🟡 Lines 78.9% 4760/6033

Test suite run success

833 tests passing in 120 suites.

Report generated by 🧪jest coverage report action from 91c2033

Please sign in to comment.