@percy/client 1.1.3 → 1.1.4
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/dist/utils.js +9 -7
- package/package.json +4 -4
- package/test/helpers.js +1 -1
package/dist/utils.js
CHANGED
|
@@ -106,6 +106,7 @@ export async function request(url, options = {}, callback) {
|
|
|
106
106
|
retryNotFound,
|
|
107
107
|
interval,
|
|
108
108
|
noProxy,
|
|
109
|
+
buffer,
|
|
109
110
|
...requestOptions
|
|
110
111
|
} = options;
|
|
111
112
|
let {
|
|
@@ -155,11 +156,13 @@ export async function request(url, options = {}, callback) {
|
|
|
155
156
|
statusCode,
|
|
156
157
|
headers
|
|
157
158
|
} = res;
|
|
158
|
-
let raw = body; //
|
|
159
|
+
let raw = body.toString('utf-8'); // only return a buffer when requested
|
|
160
|
+
|
|
161
|
+
if (buffer !== true) body = raw; // attempt to parse the body as json
|
|
159
162
|
|
|
160
163
|
try {
|
|
161
|
-
body = JSON.parse(
|
|
162
|
-
} catch
|
|
164
|
+
body = JSON.parse(raw);
|
|
165
|
+
} catch {}
|
|
163
166
|
|
|
164
167
|
try {
|
|
165
168
|
if (statusCode >= 200 && statusCode < 300) {
|
|
@@ -185,10 +188,9 @@ export async function request(url, options = {}, callback) {
|
|
|
185
188
|
};
|
|
186
189
|
|
|
187
190
|
let handleResponse = res => {
|
|
188
|
-
let
|
|
189
|
-
res.
|
|
190
|
-
res.on('
|
|
191
|
-
res.on('end', () => handleFinished(body, res));
|
|
191
|
+
let chunks = [];
|
|
192
|
+
res.on('data', chunk => chunks.push(chunk));
|
|
193
|
+
res.on('end', () => handleFinished(Buffer.concat(chunks), res));
|
|
192
194
|
res.on('error', handleError);
|
|
193
195
|
};
|
|
194
196
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@percy/client",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"test:coverage": "yarn test --coverage"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@percy/env": "1.1.
|
|
35
|
-
"@percy/logger": "1.1.
|
|
34
|
+
"@percy/env": "1.1.4",
|
|
35
|
+
"@percy/logger": "1.1.4"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "ca09298265b043703b94dd5c37dd9f2489312049"
|
|
38
38
|
}
|