All Downloads are FREE. Search and download functionalities are using the official Maven repository.

package.dist.patchFs.js Maven / Gradle / Ivy

The newest version!
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getGroupedPatches = exports.getPatchFiles = void 0;
const PackageDetails_1 = require("./PackageDetails");
const path_1 = require("./path");
const klaw_sync_1 = __importDefault(require("klaw-sync"));
const getPatchFiles = (patchesDir) => {
    try {
        return klaw_sync_1.default(patchesDir, { nodir: true })
            .map(({ path }) => path_1.relative(patchesDir, path))
            .filter((path) => path.endsWith(".patch"));
    }
    catch (e) {
        return [];
    }
};
exports.getPatchFiles = getPatchFiles;
const getGroupedPatches = (patchesDirectory) => {
    const files = exports.getPatchFiles(patchesDirectory);
    if (files.length === 0) {
        return {
            numPatchFiles: 0,
            pathSpecifierToPatchFiles: {},
            warnings: [],
        };
    }
    const warnings = [];
    const pathSpecifierToPatchFiles = {};
    for (const file of files) {
        const details = PackageDetails_1.getPackageDetailsFromPatchFilename(file);
        if (!details) {
            warnings.push(`Unrecognized patch file in patches directory ${file}`);
            continue;
        }
        if (!pathSpecifierToPatchFiles[details.pathSpecifier]) {
            pathSpecifierToPatchFiles[details.pathSpecifier] = [];
        }
        pathSpecifierToPatchFiles[details.pathSpecifier].push(details);
    }
    for (const arr of Object.values(pathSpecifierToPatchFiles)) {
        arr.sort((a, b) => {
            var _a, _b;
            return ((_a = a.sequenceNumber) !== null && _a !== void 0 ? _a : 0) - ((_b = b.sequenceNumber) !== null && _b !== void 0 ? _b : 0);
        });
    }
    return {
        numPatchFiles: files.length,
        pathSpecifierToPatchFiles,
        warnings,
    };
};
exports.getGroupedPatches = getGroupedPatches;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGF0Y2hGcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9wYXRjaEZzLnRzIl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