This repository was archived by the owner on Mar 11, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +34
-3
lines changed
Expand file tree Collapse file tree 4 files changed +34
-3
lines changed Original file line number Diff line number Diff line change 11# 4.1.2 (2019-07-29)
2- - [ NEW ] Plugins can now be loaded from outside of the 'plugins/' directory
2+ - [ FIXED ] Plugins can now be loaded from outside of the 'plugins/' directory
33
44# 4.1.1 (2019-06-17)
55- [ FIXED] Remove unnecessary ` npm-cli-login ` dependency.
Original file line number Diff line number Diff line change @@ -102,7 +102,7 @@ class CloudantClient {
102102 var pluginName = Object . keys ( plugin ) [ 0 ] ;
103103
104104 try {
105- Plugin = require ( '../plugins/' + pluginName ) ;
105+ Plugin = require ( self . _buildPluginPath ( pluginName ) ) ;
106106 } catch ( e ) {
107107 throw new Error ( `Failed to load plugin - ${ e . message } ` ) ;
108108 }
@@ -120,7 +120,7 @@ class CloudantClient {
120120 }
121121
122122 try {
123- Plugin = require ( '../plugins/' + plugin ) ;
123+ Plugin = require ( self . _buildPluginPath ( plugin ) ) ;
124124 } catch ( e ) {
125125 throw new Error ( `Failed to load plugin - ${ e . message } ` ) ;
126126 }
Original file line number Diff line number Diff line change @@ -102,6 +102,14 @@ describe('CloudantClient', function() {
102102 assert . equal ( cloudantClient . _buildPluginPath ( '/plugins/dummy-plugin' ) , '/plugins/dummy-plugin' ) ;
103103 } ) ;
104104
105+ it ( 'load plugin from custom path' , function ( ) {
106+ let ownPlugin = 'test/fixtures/testplugin.js' ;
107+ var cloudantClient = new Client ( {
108+ plugins : [ ownPlugin ]
109+ } ) ;
110+ assert . equal ( cloudantClient . _plugins . length , 1 ) ;
111+ } ) ;
112+
105113 it ( 'adds cookie authentication plugin if no other plugins are specified' , function ( ) {
106114 var cloudantClient = new Client ( ) ;
107115 assert . equal ( cloudantClient . _plugins . length , 1 ) ;
Original file line number Diff line number Diff line change 1+ // Copyright © 2017, 2018 IBM Corp. All rights reserved.
2+ //
3+ // Licensed under the Apache License, Version 2.0 (the "License");
4+ // you may not use this file except in compliance with the License.
5+ // You may obtain a copy of the License at
6+ //
7+ // http://www.apache.org/licenses/LICENSE-2.0
8+ //
9+ // Unless required by applicable law or agreed to in writing, software
10+ // distributed under the License is distributed on an "AS IS" BASIS,
11+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ // See the License for the specific language governing permissions and
13+ // limitations under the License.
14+ 'use strict' ;
15+
16+ const BasePlugin = require ( '../../plugins/base.js' ) ;
17+
18+ class TestPlugin extends BasePlugin {
19+ }
20+
21+ TestPlugin . id = 'test' ;
22+
23+ module . exports = TestPlugin ;
You can’t perform that action at this time.
0 commit comments