Closed spezifant closed 5 years ago
Hey, nice work 👍 I think we just need to use this helper, is this right?
diff --git a/lib/client.js b/lib/client.js
index 6d133a6..a2812e2 100644
--- a/lib/client.js
+++ b/lib/client.js
@@ -120,7 +120,7 @@ class CloudantClient {
}
try {
- Plugin = require('../plugins/' + plugin);
+ Plugin = require(self._buildPluginPath(plugin));
} catch (e) {
throw new Error(`Failed to load plugin - ${e.message}`);
}
Can you update the PR and also add a test that uses a custom plugin? Thanks.
@smithsz thanks for the feedback. The function all was actually missing, yes. Also added a test to load a "real" plugin from some different directory than plugins/
.
Allow plugins to be loaded from an absolute or relative path
Checklist
CHANGES.md
|CHANGELOG.md
) or test/build only changesDescription
Allow to load plugins based on a relative or absolute path.
Approach
Right now plugins can only be loaded if they reside in the
plugins/
directory of the Cloudant NPM module. With this change it's possible to load a plugin from an arbitrary file system location.Example:
Schema & API Changes
No change
Security and Privacy
No Change
Testing
plugin support.get plugin path by name
plugin support.get plugin path by relative path
plugin support.get plugin path by absolute path
Monitoring and Logging
No change