HEX
Server: Apache
System: Linux webd004.cluster130.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64
User: frenchy (106757)
PHP: 7.4.33
Disabled: _dyuweyrj4,_dyuweyrj4r,dl
Upload Files
File: /home/frenchy/www/french-american.org/current/node_modules/snyk/dist/lib/protect/fetch-patch.js
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
const needle = require("needle");
const fs = require("fs");
const analytics = require("../analytics");
const debugModule = require("debug");
const proxyFromEnv = require("proxy-from-env");
const ProxyAgent = require("proxy-agent");
const debug = debugModule('snyk:fetch-patch');
const getProxyForUrl = proxyFromEnv.getProxyForUrl;
function getPatchFile(patchUrl, patchFilename) {
    return __awaiter(this, void 0, void 0, function* () {
        let options;
        const proxyUri = getProxyForUrl(patchUrl);
        if (proxyUri) {
            debug('Using proxy: ', proxyUri);
            options = { agent: new ProxyAgent(proxyUri) };
        }
        let res;
        let patchData;
        try {
            res = yield needle('get', patchUrl, options || {});
            if (!res || res.statusCode !== 200) {
                throw res;
            }
            patchData = res.body;
            debug(`Successfully downloaded patch from ${patchUrl}, patch size ${patchData.length} bytes`);
        }
        catch (error) {
            debug(`Failed to download patch from ${patchUrl}`, error);
            analytics.add('patch-fetch-fail', {
                message: error && (error.message || error.body),
                code: error && error.statusCode,
            });
            throw error;
        }
        try {
            fs.writeFileSync(patchFilename, patchData);
            debug(`Successfully wrote patch to ${patchFilename}`);
        }
        catch (error) {
            debug(`Failed to write patch to ${patchFilename}`, error);
            analytics.add('patch-fetch-fail', {
                message: error && error.message,
                patchFilename,
                patchUrl,
            });
            throw error;
        }
        return patchFilename;
    });
}
module.exports = getPatchFile;
//# sourceMappingURL=fetch-patch.js.map