aggregation-repository-provider
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -8,4 +8,19 @@ 'use strict'; | ||
/** | ||
* <!-- skip-example --> | ||
* Combines several repository providers into one | ||
* @param {Provider[]} providers | ||
* @property {Provider[]} providers | ||
* @example | ||
* const provider = new AggregationProvider([ | ||
* new GithubProvider(), | ||
* new BitbucketProvider() | ||
* ]); | ||
* const repository1 = await provider.repository( | ||
* 'https://github.com/arlac77/aggregation-repository-provider' | ||
* ); | ||
* const repository2 = await provider.repository( | ||
* 'https://arlac77@bitbucket.org/arlac77/sync-test-repository.git' | ||
* ); | ||
* // repository1 -> github | ||
* // repository2 -> bitbucket | ||
*/ | ||
@@ -19,3 +34,4 @@ class AggregationProvider extends repositoryProvider.Provider { | ||
/** | ||
* Retrieve named repository in one of the given providers | ||
* Retrieve named repository in one of the given providers. | ||
* They are consulted in the order of the propviders given to the constructor | ||
* @param {string} name | ||
@@ -25,6 +41,10 @@ * @return {Repository} | ||
async repository(name) { | ||
const matches = await Promise.all( | ||
this.providers.map(provider => provider.repository(name)) | ||
); | ||
return matches.find(p => p !== undefined); | ||
for (const p of this.providers) { | ||
const r = await p.repository(name); | ||
if (r !== undefined) { | ||
return r; | ||
} | ||
} | ||
return undefined; | ||
} | ||
@@ -31,0 +51,0 @@ } |
{ | ||
"name": "aggregation-repository-provider", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"main": "dist/repository-provider.js", | ||
@@ -8,3 +8,3 @@ "module": "src/repository-provider.js", | ||
"keywords": [ | ||
"npm-package-template" | ||
"repository-provider" | ||
], | ||
@@ -31,15 +31,16 @@ "contributors": [ | ||
"dependencies": { | ||
"repository-provider": "^2.12.0" | ||
"repository-provider": "^2.17.0" | ||
}, | ||
"devDependencies": { | ||
"ava": "^0.24.0", | ||
"bitbucket-repository-provider": "^1.2.1", | ||
"ava": "^0.25.0", | ||
"bitbucket-repository-provider": "^1.2.3", | ||
"documentation": "^5.3.5", | ||
"github-repository-provider": "^1.5.1", | ||
"github-repository-provider": "^2.0.0", | ||
"local-repository-provider": "^1.1.5", | ||
"markdown-doctest": "^0.9.1", | ||
"nyc": "^11.4.1", | ||
"rollup": "^0.54.1", | ||
"rollup": "^0.55.1", | ||
"rollup-plugin-multi-entry": "^2.0.2", | ||
"semantic-release": "^12.2.3", | ||
"travis-deploy-once": "^4.3.2" | ||
"semantic-release": "^13.0.2", | ||
"travis-deploy-once": "^4.3.3" | ||
}, | ||
@@ -51,3 +52,3 @@ "engines": { | ||
"type": "git", | ||
"url": "git+https://github.com/arlac77/aggregation-repository-provider.git" | ||
"url": "https://github.com/arlac77/aggregation-repository-provider.git" | ||
}, | ||
@@ -54,0 +55,0 @@ "bugs": { |
@@ -36,2 +36,4 @@ [](https://www.npmjs.com/package/aggregation-repository-provider) | ||
<!-- skip-example --> | ||
Combines several repository providers into one | ||
@@ -43,5 +45,27 @@ | ||
**Properties** | ||
- `providers` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<Provider>** | ||
**Examples** | ||
```javascript | ||
const provider = new AggregationProvider([ | ||
new GithubProvider(), | ||
new BitbucketProvider() | ||
]); | ||
const repository1 = await provider.repository( | ||
'https://github.com/arlac77/aggregation-repository-provider' | ||
); | ||
const repository2 = await provider.repository( | ||
'https://arlac77@bitbucket.org/arlac77/sync-test-repository.git' | ||
); | ||
// repository1 -> github | ||
// repository2 -> bitbucket | ||
``` | ||
### repository | ||
Retrieve named repository in one of the given providers | ||
Retrieve named repository in one of the given providers. | ||
They are consulted in the order of the propviders given to the constructor | ||
@@ -48,0 +72,0 @@ **Parameters** |
import { Provider } from 'repository-provider'; | ||
/** | ||
* <!-- skip-example --> | ||
* Combines several repository providers into one | ||
* @param {Provider[]} providers | ||
* @property {Provider[]} providers | ||
* @example | ||
* const provider = new AggregationProvider([ | ||
* new GithubProvider(), | ||
* new BitbucketProvider() | ||
* ]); | ||
* const repository1 = await provider.repository( | ||
* 'https://github.com/arlac77/aggregation-repository-provider' | ||
* ); | ||
* const repository2 = await provider.repository( | ||
* 'https://arlac77@bitbucket.org/arlac77/sync-test-repository.git' | ||
* ); | ||
* // repository1 -> github | ||
* // repository2 -> bitbucket | ||
*/ | ||
@@ -14,3 +29,4 @@ export class AggregationProvider extends Provider { | ||
/** | ||
* Retrieve named repository in one of the given providers | ||
* Retrieve named repository in one of the given providers. | ||
* They are consulted in the order of the propviders given to the constructor | ||
* @param {string} name | ||
@@ -20,7 +36,11 @@ * @return {Repository} | ||
async repository(name) { | ||
const matches = await Promise.all( | ||
this.providers.map(provider => provider.repository(name)) | ||
); | ||
return matches.find(p => p !== undefined); | ||
for (const p of this.providers) { | ||
const r = await p.repository(name); | ||
if (r !== undefined) { | ||
return r; | ||
} | ||
} | ||
return undefined; | ||
} | ||
} |
10217
168
85
87
11
Updatedrepository-provider@^2.17.0