Merge pull request #122 from vergara/fix-user
Added support for external providers as npm modules.
This commit is contained in:
commit
b6e06dbceb
|
@ -84,8 +84,17 @@ function createClient(options) {
|
|||
// Try to load the provider from providers folder
|
||||
handler = require('./providers/' + provider);
|
||||
} catch (err) {
|
||||
// Fall back to pkgcloud
|
||||
handler = require('pkgcloud').storage;
|
||||
try {
|
||||
// Fall back to using an external provider
|
||||
handler = require(provider);
|
||||
if (!handler || !handler.createClient) {
|
||||
// Fall back to pkgcloud
|
||||
handler = require('pkgcloud').storage;
|
||||
}
|
||||
} catch(err) {
|
||||
// Fall back to pkgcloud
|
||||
handler = require('pkgcloud').storage;
|
||||
}
|
||||
}
|
||||
patchContainerAndFileClass(provider);
|
||||
return handler.createClient(options);
|
||||
|
@ -101,8 +110,13 @@ function getProvider(provider) {
|
|||
// Try to load the provider from providers folder
|
||||
return require('./providers/' + provider);
|
||||
} catch (err) {
|
||||
// Fall back to pkgcloud
|
||||
return require('pkgcloud').providers[provider];
|
||||
try {
|
||||
// Fall back to using an external provider
|
||||
return require(provider);
|
||||
} catch(err) {
|
||||
// Fall back to pkgcloud
|
||||
return require('pkgcloud').providers[provider];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue