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
|
// Try to load the provider from providers folder
|
||||||
handler = require('./providers/' + provider);
|
handler = require('./providers/' + provider);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// Fall back to pkgcloud
|
try {
|
||||||
handler = require('pkgcloud').storage;
|
// 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);
|
patchContainerAndFileClass(provider);
|
||||||
return handler.createClient(options);
|
return handler.createClient(options);
|
||||||
|
@ -101,8 +110,13 @@ function getProvider(provider) {
|
||||||
// Try to load the provider from providers folder
|
// Try to load the provider from providers folder
|
||||||
return require('./providers/' + provider);
|
return require('./providers/' + provider);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// Fall back to pkgcloud
|
try {
|
||||||
return require('pkgcloud').providers[provider];
|
// 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