snyk 1.1165.0 → 1.1167.0
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/cli/917.index.js
CHANGED
|
@@ -5209,7 +5209,7 @@ exports.fetchCacheResource = exports.InvalidUserPathError = exports.lookupLocal
|
|
|
5209
5209
|
const createDebugLogger = __webpack_require__(15158);
|
|
5210
5210
|
const path = __webpack_require__(85622);
|
|
5211
5211
|
const errors_1 = __webpack_require__(55191);
|
|
5212
|
-
const request_1 = __webpack_require__(
|
|
5212
|
+
const request_1 = __webpack_require__(1552);
|
|
5213
5213
|
const debugLogger = createDebugLogger('snyk-iac');
|
|
5214
5214
|
async function lookupLocal(iacCachePath, resourceName, userResourcePath, validResourceCondition) {
|
|
5215
5215
|
// Lookup in custom path.
|
|
@@ -5239,15 +5239,29 @@ class InvalidUserPathError extends errors_1.CustomError {
|
|
|
5239
5239
|
}
|
|
5240
5240
|
exports.InvalidUserPathError = InvalidUserPathError;
|
|
5241
5241
|
async function fetchCacheResource(url) {
|
|
5242
|
-
const
|
|
5243
|
-
|
|
5242
|
+
const stream = await request_1.streamRequest({
|
|
5243
|
+
body: null,
|
|
5244
|
+
headers: {},
|
|
5245
|
+
method: 'get',
|
|
5246
|
+
url: url,
|
|
5244
5247
|
});
|
|
5245
|
-
|
|
5246
|
-
throw new errors_1.CustomError(`Failed to download cache resource from ${url}`);
|
|
5247
|
-
}
|
|
5248
|
-
return cacheResourceBuffer;
|
|
5248
|
+
return streamToBuffer(stream);
|
|
5249
5249
|
}
|
|
5250
5250
|
exports.fetchCacheResource = fetchCacheResource;
|
|
5251
|
+
async function streamToBuffer(stream) {
|
|
5252
|
+
return new Promise((resolve, reject) => {
|
|
5253
|
+
const chunks = [];
|
|
5254
|
+
stream.on('data', (chunk) => {
|
|
5255
|
+
chunks.push(chunk);
|
|
5256
|
+
});
|
|
5257
|
+
stream.on('end', () => {
|
|
5258
|
+
resolve(Buffer.concat(chunks));
|
|
5259
|
+
});
|
|
5260
|
+
stream.on('error', (err) => {
|
|
5261
|
+
reject(err);
|
|
5262
|
+
});
|
|
5263
|
+
});
|
|
5264
|
+
}
|
|
5251
5265
|
|
|
5252
5266
|
|
|
5253
5267
|
/***/ }),
|