github-repository-provider 7.23.22 → 7.23.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "github-repository-provider",
3
- "version": "7.23.22",
3
+ "version": "7.23.26",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -30,19 +30,19 @@
30
30
  "lint:docs": "documentation lint ./src/**/*.mjs"
31
31
  },
32
32
  "dependencies": {
33
- "content-entry": "^2.7.0",
33
+ "content-entry": "^2.9.1",
34
34
  "fetch-link-util": "^1.0.4",
35
35
  "fetch-rate-limit-util": "^1.1.6",
36
36
  "matching-iterator": "^2.0.0",
37
37
  "node-fetch": "3.0.0",
38
38
  "one-time-execution-method": "^2.0.9",
39
- "repository-provider": "^25.5.6"
39
+ "repository-provider": "^25.5.7"
40
40
  },
41
41
  "devDependencies": {
42
42
  "ava": "^3.15.0",
43
43
  "c8": "^7.10.0",
44
44
  "documentation": "^13.2.5",
45
- "repository-provider-test-support": "^1.6.1",
45
+ "repository-provider-test-support": "^1.6.4",
46
46
  "semantic-release": "^18.0.0"
47
47
  },
48
48
  "engines": {
@@ -127,12 +127,12 @@ export class GithubBranch extends Branch {
127
127
  `repos/${this.slug}/contents/${name}?ref=${this.ref}`
128
128
  );
129
129
 
130
- if (res.status != 200) {
131
- throw new Error(res.status);
130
+ if (res.ok) {
131
+ const json = await res.json();
132
+ return new this.entryClass(name, Buffer.from(json.content, "base64"));
132
133
  }
133
- const json = await res.json();
134
134
 
135
- return new this.entryClass(name, Buffer.from(json.content, "base64"));
135
+ throw new Error(res.status);
136
136
  }
137
137
 
138
138
  /** @inheritdoc */
@@ -140,12 +140,10 @@ export class GithubBranch extends Branch {
140
140
  const res = await this.provider.fetch(
141
141
  `repos/${this.slug}/contents/${name}?ref=${this.ref}`
142
142
  );
143
- if (res.status === 404) {
144
- return undefined;
143
+ if(res.ok) {
144
+ const json = await res.json();
145
+ return new this.entryClass(name, Buffer.from(json.content, "base64"));
145
146
  }
146
-
147
- const json = await res.json();
148
- return new this.entryClass(name, Buffer.from(json.content, "base64"));
149
147
  }
150
148
 
151
149
  /**
@@ -153,11 +151,18 @@ export class GithubBranch extends Branch {
153
151
  * @param tree_sha
154
152
  */
155
153
  async tree(tree_sha) {
156
- const res = await this.provider.fetch(
157
- `repos/${this.slug}/git/trees/${tree_sha}?recursive=1`
158
- );
154
+ const url = `repos/${this.slug}/git/trees/${tree_sha}?recursive=1`;
155
+ let res;
156
+
157
+ for(const i = 0; i < 2; i++) {
158
+ res = await this.provider.fetch(url);
159
+ if(res.ok) {
160
+ break;
161
+ }
162
+ }
163
+
159
164
  const json = await res.json();
160
- return json.tree;
165
+ return json.tree;
161
166
  }
162
167
 
163
168
  async *entries(patterns) {
@@ -198,6 +203,10 @@ class LazyBufferContentEntry extends BufferContentEntryMixin(ContentEntry) {
198
203
  });
199
204
  }
200
205
 
206
+ get buffer() {
207
+ return this.getBuffer();
208
+ }
209
+
201
210
  async getBuffer() {
202
211
  if(this._buffer) { return this._buffer; }
203
212