MCPcopy
hub / github.com/Kong/insomnia / fetchFromExternal

Method fetchFromExternal

packages/insomnia/bin/yarn-standalone.js:64628–64680  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

64626 }
64627
64628 fetchFromExternal() {
64629 var _this3 = this;
64630
64631 return (0, (_asyncToGenerator2 || _load_asyncToGenerator()).default)(function* () {
64632 const registry = _this3.config.registries[_this3.registry];
64633
64634 try {
64635 const headers = _this3.requestHeaders();
64636 return yield registry.request(_this3.reference, {
64637 headers: (0, (_extends2 || _load_extends()).default)({
64638 'Accept-Encoding': 'gzip'
64639 }, headers),
64640 buffer: true,
64641 process: function process(req, resolve, reject) {
64642 // should we save this to the offline cache?
64643 const tarballMirrorPath = _this3.getTarballMirrorPath();
64644 const tarballCachePath = _this3.getTarballCachePath();
64645
64646 var _createExtractor2 = _this3.createExtractor(resolve, reject);
64647
64648 const validateStream = _createExtractor2.validateStream,
64649 extractorStream = _createExtractor2.extractorStream;
64650
64651
64652 req.pipe(validateStream);
64653
64654 if (tarballMirrorPath) {
64655 validateStream.pipe(fs.createWriteStream(tarballMirrorPath)).on('error', reject);
64656 }
64657
64658 if (tarballCachePath) {
64659 validateStream.pipe(fs.createWriteStream(tarballCachePath)).on('error', reject);
64660 }
64661
64662 validateStream.pipe(extractorStream).on('error', reject);
64663 }
64664 }, _this3.packageName);
64665 } catch (err) {
64666 const tarballMirrorPath = _this3.getTarballMirrorPath();
64667 const tarballCachePath = _this3.getTarballCachePath();
64668
64669 if (tarballMirrorPath && (yield (_fs || _load_fs()).exists(tarballMirrorPath))) {
64670 yield (_fs || _load_fs()).unlink(tarballMirrorPath);
64671 }
64672
64673 if (tarballCachePath && (yield (_fs || _load_fs()).exists(tarballCachePath))) {
64674 yield (_fs || _load_fs()).unlink(tarballCachePath);
64675 }
64676
64677 throw err;
64678 }
64679 })();
64680 }
64681
64682 requestHeaders() {
64683 const registry = this.config.registries.yarn;

Callers 1

_fetchMethod · 0.95

Calls 9

_load_asyncToGeneratorFunction · 0.85
_load_extendsFunction · 0.85
_load_fsFunction · 0.85
requestHeadersMethod · 0.80
createExtractorMethod · 0.80
requestMethod · 0.45
getTarballMirrorPathMethod · 0.45
getTarballCachePathMethod · 0.45
unlinkMethod · 0.45

Tested by

no test coverage detected