MOON
Server: Apache
System: Linux nserver.cafsindia.com 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: cafsindia (1002)
PHP: 8.2.30
Disabled: NONE
Upload Files
File: //home/cafsindia/snap.cafsinfotech.in/node_modules/@commitlint/load/lib/utils/load-parser-opts.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.loadParserOpts = void 0;
function isObjectLike(obj) {
    return Boolean(obj) && typeof obj === 'object'; // typeof null === 'object'
}
function isParserOptsFunction(obj) {
    return typeof obj.parserOpts === 'function';
}
async function loadParserOpts(pendingParser) {
    if (typeof pendingParser === 'function') {
        return loadParserOpts(pendingParser());
    }
    if (!pendingParser || typeof pendingParser !== 'object') {
        return undefined;
    }
    // Await for the module, loaded with require
    const parser = await pendingParser;
    // exit early, no opts to resolve
    if (!parser.parserOpts) {
        return parser;
    }
    // Pull nested parserOpts, might happen if overwritten with a module in main config
    if (typeof parser.parserOpts === 'object') {
        // Await parser opts if applicable
        parser.parserOpts = await parser.parserOpts;
        if (isObjectLike(parser.parserOpts) &&
            isObjectLike(parser.parserOpts.parserOpts)) {
            parser.parserOpts = parser.parserOpts.parserOpts;
        }
        return parser;
    }
    // Create parser opts from factory
    if (isParserOptsFunction(parser) &&
        typeof parser.name === 'string' &&
        parser.name.startsWith('conventional-changelog-')) {
        return new Promise((resolve) => {
            const result = parser.parserOpts((_, opts) => {
                resolve(Object.assign(Object.assign({}, parser), { parserOpts: opts === null || opts === void 0 ? void 0 : opts.parserOpts }));
            });
            // If result has data or a promise, the parser doesn't support factory-init
            // due to https://github.com/nodejs/promises-debugging/issues/16 it just quits, so let's use this fallback
            if (result) {
                Promise.resolve(result).then((opts) => {
                    resolve(Object.assign(Object.assign({}, parser), { parserOpts: opts === null || opts === void 0 ? void 0 : opts.parserOpts }));
                });
            }
            return;
        });
    }
    return parser;
}
exports.loadParserOpts = loadParserOpts;
//# sourceMappingURL=load-parser-opts.js.map