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,GAAe,KAEX,MAAM,QAAQ,EAAW,cAAgB,EAAW,YAAY,OAAS,EACzE,GAAe,EAAW,YAAY,KAAK,GAEV,iBAAlB,EAEA,EAAc,MAAQ,EAAc,KAGlB,iBAAlB,EACA,OADX,IAK8B,iBAA3B,EAAW,cACjB,EAAW,YAAY,MAAQ,EAAW,YAAY,MAEvD,GAAe,EAAW,YAAY,MAAQ,EAAW,YAAY,KAC5B,iBAA3B,EAAW,cACzB,GAAe,GAAG,aAAa,EAAW,YAAa,CAAE,SAAU,UAGhE,CAAW,IAErB,KAAK,OACd,EAEA,QAAQ,UAAY,SAAmB,GACnC,GAAwB,iBAAb,EACP,OAAO,IAAI,MAAM,0DAGrB,IACI,MAAM,EAAmB,GAAG,aAAa,EAAU,CAAE,SAAU,SAE/D,OAAO,KAAK,MAAM,EACtB,CAAE,MAAO,GACL,OAAO,CACX,CACJ,EAEA,QAAQ,QAAU,SAAiB,EAAM,GACrC,OAAO,KAAK,GAEZ,OAAO,KAAK,GAAM,SAAS,IACvB,MAAM,EAAc,EAAK,GAAY,YAErC,GAAI,GAAe,GAAG,WAAW,GAAc,CAC3C,MAAM,EAAe,GAAG,aAAa,GAC/B,EAAU,KAAK,KAAK,EAAQ,GAAG,iBAC/B,EAAU,KAAK,QAAQ,GAE7B,OAAO,KAAK,GACZ,GAAG,cAAc,EAAS,EAAc,OAC5C,MACI,QAAQ,KAAK,qCAAqC,KACtD,GAER","file":"/npm/npm-license-checker-alt@1.0.3/lib/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/npm-license-checker-alt@1.0.3/lib/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/*\nCopyright (c) 2013, Yahoo! Inc. All rights reserved.\nCode licensed under the BSD License:\nhttp://yuilibrary.com/license/\n*/\n\nconst UNKNOWN = 'UNKNOWN';\nconst UNLICENSED = 'UNLICENSED';\n\nconst chalk = require('chalk');\nconst debug = require('debug');\nconst fs = require('fs');\nconst mkdirp = require('mkdirp');\nconst path = require('path');\nconst read = require('read-installed-packages');\nconst spdxCorrect = require('spdx-correct');\nconst spdxSatisfies = require('spdx-satisfies');\nconst treeify = require('treeify');\n\nconst getLicenseTitle = require('./getLicenseTitle');\nconst licenseFiles = require('./license-files');\n\n// Set up debug logging\n// https://www.npmjs.com/package/debug#stderr-vs-stdout\nconst debugError = debug('license-checker-rseidelsohn:error');\nconst debugLog = debug('license-checker-rseidelsohn:log');\n\ndebugLog.log = console.log.bind(console);\n\n// This function calls itself recursively. On the first iteration, it collects the data of the main program, during the\n// second iteration, it collects the data from all direct dependencies, then it collects their dependencies and so on.\nconst flatten = function flatten(options) {\n    const moduleInfo = { licenses: UNKNOWN };\n    const { color: colorize, deps: json, unknown } = options;\n    const key = `${json.name}@${json.version}`;\n    let dirFiles;\n    let files = [];\n    let licenseData;\n    let licenseFile;\n    let noticeFiles = [];\n    let readmeFile;\n    let { data } = options;\n\n    if (json.private) {\n        moduleInfo.private = true;\n    }\n\n    // If we have processed this key already, just return the data object.\n    // This was added so that we don't recurse forever if there was a circular\n    // dependency in the dependency tree.\n    /*istanbul ignore next*/\n    if (data[key]) {\n        return data;\n    }\n\n    if ((options.production && json.extraneous) || (options.development && !json.extraneous && !json.root)) {\n        return data;\n    }\n\n    data[key] = moduleInfo;\n\n    // Include property in output unless custom format has set property to false.\n    function mustInclude(property) {\n        return options?.customFormat?.[property] !== false;\n    }\n\n    if (mustInclude('repository') && json.repository) {\n        /*istanbul ignore else*/\n        if (typeof json?.repository?.url === 'string') {\n            moduleInfo.repository = json.repository.url\n                .replace('git+ssh://git@', 'git://')\n                .replace('git+https://github.com', 'https://github.com')\n                .replace('git://github.com', 'https://github.com')\n                .replace('git@github.com:', 'https://github.com/')\n                .replace(/\\.git$/, '');\n        }\n    }\n\n    if (mustInclude('url') && json?.url?.we) {\n        /*istanbul ignore next*/\n        moduleInfo.url = json.url.web;\n    }\n\n    if (json.author && typeof json.author === 'object') {\n        /*istanbul ignore else - This should always be there*/\n        if (mustInclude('publisher') && json.author.name) {\n            moduleInfo.publisher = json.author.name;\n        }\n\n        if (mustInclude('email') && json.author.email) {\n            moduleInfo.email = json.author.email;\n        }\n\n        if (mustInclude('url') && json.author.url) {\n            moduleInfo.url = json.author.url;\n        }\n    }\n\n    /*istanbul ignore next*/\n    if (unknown) {\n        moduleInfo.dependencyPath = json.path;\n    }\n\n    if (mustInclude('path') && typeof json?.path === 'string') {\n        moduleInfo.path = json.path;\n    }\n\n    licenseData = json.license || json.licenses || undefined;\n\n    if (json.path && (!json.readme || json.readme.toLowerCase().indexOf('no readme data found') > -1)) {\n        readmeFile = path.join(json.path, 'README.md');\n        /*istanbul ignore if*/\n        if (fs.existsSync(readmeFile)) {\n            json.readme = fs.readFileSync(readmeFile, 'utf8').toString();\n        }\n    }\n\n    if (licenseData) {\n        /*istanbul ignore else*/\n        if (Array.isArray(licenseData) && licenseData.length > 0) {\n            moduleInfo.licenses = licenseData.map((moduleLicense) => {\n                /*istanbul ignore else*/\n                if (typeof moduleLicense === 'object') {\n                    /*istanbul ignore next*/\n                    return moduleLicense.type || moduleLicense.name;\n                }\n\n                if (typeof moduleLicense === 'string') {\n                    return moduleLicense;\n                }\n            });\n        } else if (typeof licenseData === 'object' && (licenseData.type || licenseData.name)) {\n            moduleInfo.licenses = getLicenseTitle(licenseData.type || licenseData.name);\n        } else if (typeof licenseData === 'string') {\n            moduleInfo.licenses = getLicenseTitle(licenseData);\n        }\n    } else if (getLicenseTitle(json.readme)) {\n        moduleInfo.licenses = getLicenseTitle(json.readme);\n    }\n\n    if (Array.isArray(moduleInfo.licenses)) {\n        /*istanbul ignore else*/\n        if (moduleInfo.licenses.length === 1) {\n            moduleInfo.licenses = moduleInfo.licenses[0];\n        }\n    }\n\n    /*istanbul ignore else*/\n    if (fs.existsSync(json?.path)) {\n        dirFiles = fs.readdirSync(json.path);\n        files = licenseFiles(dirFiles);\n\n        noticeFiles = dirFiles.filter((filename) => {\n            filename = filename.toUpperCase();\n            const name = path.basename(filename).replace(path.extname(filename), '');\n\n            return name === 'NOTICE';\n        });\n    }\n\n    files.forEach(function (filename, index) {\n        licenseFile = path.join(json.path, filename);\n        // Checking that the file is in fact a normal file and not a directory for example.\n        /*istanbul ignore else*/\n        if (fs.lstatSync(licenseFile).isFile()) {\n            let content;\n\n            if (\n                !moduleInfo.licenses ||\n                moduleInfo.licenses.indexOf(UNKNOWN) > -1 ||\n                moduleInfo.licenses.indexOf('Custom:') === 0\n            ) {\n                //Only re-check the license if we didn't get it from elsewhere\n                content = fs.readFileSync(licenseFile, { encoding: 'utf8' });\n                moduleInfo.licenses = getLicenseTitle(content);\n            }\n\n            if (index === 0) {\n                // Treat the file with the highest precedence as licenseFile\n                /*istanbul ignore else*/\n                if (mustInclude('licenseFile')) {\n                    moduleInfo.licenseFile = options.basePath\n                        ? path.relative(options.basePath, licenseFile)\n                        : licenseFile;\n                }\n\n                if (mustInclude('licenseText') && options.customFormat) {\n                    if (!content) {\n                        content = fs.readFileSync(licenseFile, { encoding: 'utf8' });\n                    }\n\n                    /*istanbul ignore else*/\n                    if (options._args && !options._args.csv) {\n                        moduleInfo.licenseText = content.trim();\n                    } else {\n                        moduleInfo.licenseText = content\n                            .replace(/\"/g, \"'\")\n                            .replace(/\\r?\\n|\\r/g, ' ')\n                            .trim();\n                    }\n                }\n\n                if (mustInclude('copyright') && options.customFormat) {\n                    if (!content) {\n                        content = fs.readFileSync(licenseFile, { encoding: 'utf8' });\n                    }\n\n                    const linesWithCopyright = content\n                        .replace(/\\r\\n/g, '\\n')\n                        .split('\\n\\n')\n                        .filter(function selectCopyRightStatements(value) {\n                            return (\n                                value.startsWith('opyright', 1) && // include copyright statements\n                                !value.startsWith('opyright notice', 1) && // exclude lines from from license text\n                                !value.startsWith('opyright and related rights', 1)\n                            );\n                        })\n                        .filter(function removeDuplicates(value, index, list) {\n                            return index === 0 || value !== list[0];\n                        });\n\n                    if (linesWithCopyright.length > 0) {\n                        moduleInfo.copyright = linesWithCopyright[0].replace(/\\n/g, '. ').trim();\n                    }\n\n                    // Mark files with multiple copyright statements. This might be\n                    // an indicator to take a closer look at the LICENSE file.\n                    if (linesWithCopyright.length > 1) {\n                        moduleInfo.copyright = `${moduleInfo.copyright}*`;\n                    }\n                }\n            }\n        }\n    });\n\n    noticeFiles.forEach((filename) => {\n        const file = path.join(json.path, filename);\n        /*istanbul ignore else*/\n        if (fs.lstatSync(file).isFile()) {\n            moduleInfo.noticeFile = options.basePath ? path.relative(options.basePath, file) : file;\n        }\n    });\n\n    /*istanbul ignore else*/\n    if (json.dependencies) {\n        Object.keys(json.dependencies).forEach((name) => {\n            const childDependency = options.depth > options._args.direct ? {} : json.dependencies[name];\n            const dependencyId = `${childDependency.name}@${childDependency.version}`;\n\n            if (data[dependencyId]) {\n                // already exists\n                return;\n            }\n\n            data = flatten({\n                _args: options._args,\n                basePath: options.basePath,\n                color: colorize,\n                customFormat: options.customFormat,\n                data,\n                deps: childDependency,\n                development: options.development,\n                production: options.production,\n                unknown,\n                depth: options.depth + 1,\n            });\n        });\n    }\n\n    if (!json.name || !json.version) {\n        delete data[key];\n    }\n\n    /*istanbul ignore next*/\n    if (options.customFormat) {\n        Object.keys(options.customFormat).forEach((item) => {\n            if (mustInclude(item) && moduleInfo[item] == null) {\n                moduleInfo[item] = typeof json[item] === 'string' ? json[item] : options.customFormat[item];\n            }\n        });\n    }\n\n    return data;\n};\n\n/**\n * ! This function has a wanted sideeffect, as it modifies the json object that is passed by reference.\n *\n *  The detph attribute set in the opts parameter here - which is defined by setting the `--direct` flag - is of\n *  no use with npm > 2, as the newer npm versions flatten all dependencies into one single directory. So in\n *  order to making `--direct` work with newer versions of npm, we need to filter out all non-dependencies from\n *  the json result.\n */\nconst removeUnwantedDependencies = (json, args) => {\n    if (args.direct === 0) {\n        const allDependencies = Object.keys(json.dependencies);\n        let wantedDependencies = [];\n\n        if (args.production && !args.development) {\n            const devDependencies = Object.keys(json.devDependencies);\n            wantedDependencies = Object.keys(json._dependencies).filter(\n                (directDependency) => !devDependencies.includes(directDependency),\n            );\n        } else if (!args.production && args.development) {\n            wantedDependencies = Object.keys(json.devDependencies);\n        } else {\n            wantedDependencies = Object.keys(json._dependencies);\n        }\n\n        allDependencies.forEach((currentDependency) => {\n            if (!wantedDependencies.includes(currentDependency)) {\n                delete json.dependencies[currentDependency];\n            }\n        });\n    }\n};\n\nexports.init = function init(args, callback) {\n    // Fix path if on Windows:\n    const workingDir = args.start.replace(/\\\\\\\\/g, '\\\\');\n\n    debugLog('scanning %s', args.start);\n\n    if (args.customPath) {\n        args.customFormat = this.parseJson(args.customPath);\n    }\n\n    const opts = {\n        depth: args.direct,\n        nopeer: args.nopeer,\n        dev: true,\n        log: debugLog,\n    };\n\n    if (args.production || args.development) {\n        opts.dev = false;\n    }\n\n    const toCheckforFailOn = [];\n    const toCheckforOnlyAllow = [];\n    let checker;\n    let pusher;\n\n    if (args.onlyAllow) {\n        checker = args.onlyAllow;\n        pusher = toCheckforOnlyAllow;\n    }\n\n    if (args.failOn) {\n        checker = args.failOn;\n        pusher = toCheckforFailOn;\n    }\n\n    if (checker && pusher) {\n        checker.split(';').forEach((license) => {\n            license = license.trim();\n            /*istanbul ignore else*/\n            if (license.length > 0) {\n                pusher.push(license);\n            }\n        });\n    }\n\n    read(args.start, opts, (err, json) => {\n        removeUnwantedDependencies(json, args);\n\n        const data = flatten({\n            _args: args,\n            basePath: args.relativeLicensePath ? json.path : null,\n            color: args.color,\n            customFormat: args.customFormat,\n            data: {},\n            deps: json,\n            development: args.development,\n            production: args.production,\n            unknown: args.unknown,\n            depth: 0,\n        });\n\n        const colorize = args.color;\n        const sorted = {};\n        let filtered = {};\n        const excludeLicenses =\n            args.excludeLicenses &&\n            args.excludeLicenses\n                .match(/([^\\\\\\][^,]|\\\\,)+/g)\n                .map((license) => license.replace(/\\\\,/g, ',').replace(/^\\s+|\\s+$/g, ''));\n        const includeLicenses =\n            args.includeLicenses &&\n            args.includeLicenses\n                .match(/([^\\\\\\][^,]|\\\\,)+/g)\n                .map((license) => license.replace(/\\\\,/g, ',').replace(/^\\s+|\\s+$/g, ''));\n        let inputError = null;\n\n        function colorizeString(string) {\n            /*istanbul ignore next*/\n            return colorize ? chalk.bold.red(string) : string;\n        }\n\n        function filterDeletePrivatePackages(privatePackage) {\n            /*istanbul ignore next - I don't have access to private packages to test */\n            if (resultJson[privatePackage] && resultJson[privatePackage].private) {\n                delete resultJson[privatePackage];\n            }\n        }\n\n        function onlyIncludeWhitelist(whitelist, filtered) {\n            const resultJson = {};\n\n            Object.keys(filtered).map((filteredPackage) => {\n                // Whitelist packages by declaring:\n                // 1. the package full name. Ex: `react` (we suffix an '@' to ensure we don't match packages like `react-native`)\n                // 2. the package full name and the major version. Ex: `react@16`\n                // 3. the package full name and full version. Ex: `react@16.0.2`\n                if (\n                    whitelist.findIndex((whitelistPackage) =>\n                        filteredPackage.startsWith(\n                            whitelistPackage.lastIndexOf('@') > 0 ? whitelistPackage : `${whitelistPackage}@`,\n                        ),\n                    ) !== -1\n                ) {\n                    resultJson[filteredPackage] = filtered[filteredPackage];\n                }\n            });\n\n            return resultJson;\n        }\n\n        function excludeBlacklist(blacklist, filtered) {\n            const resultJson = {};\n\n            Object.keys(filtered).map((filteredPackage) => {\n                // Blacklist packages by declaring:\n                // 1. the package full name. Ex: `react` (we suffix an '@' to ensure we don't match packages like `react-native`)\n                // 2. the package full name and the major version. Ex: `react@16`\n                // 3. the package full name and full version. Ex: `react@16.0.2`\n                if (\n                    blacklist.findIndex((blacklistPackage) =>\n                        filteredPackage.startsWith(\n                            blacklistPackage.lastIndexOf('@') > 0 ? blacklistPackage : `${blacklistPackage}@`,\n                        ),\n                    ) === -1\n                ) {\n                    resultJson[filteredPackage] = filtered[filteredPackage];\n                }\n            });\n\n            return resultJson;\n        }\n\n        function excludePackagesStartingWith(blacklist, filtered) {\n            const resultJson = {};\n\n            Object.keys(filtered).map((filteredPackage) => {\n                blacklist.forEach((blacklist) => {\n                    if (!filteredPackage.startsWith(blacklist)) {\n                        resultJson[filteredPackage] = filtered[filteredPackage];\n                    } else {\n                        delete filtered[filteredPackage];\n                    }\n                });\n            });\n\n            return resultJson;\n        }\n\n        function exitIfCheckHits(packageName) {\n            const currentLicense = resultJson[packageName].licenses;\n\n            checkForFailOn(currentLicense);\n            checkForOnlyAllow(currentLicense, packageName);\n        }\n\n        function checkForFailOn(currentLicense) {\n            if (toCheckforFailOn.length > 0) {\n                if (toCheckforFailOn.indexOf(currentLicense) > -1) {\n                    console.error(`Found license defined by the --failOn flag: \"${currentLicense}\". Exiting.`);\n\n                    process.exit(1);\n                }\n            }\n        }\n\n        function checkForOnlyAllow(currentLicense, packageName) {\n            if (toCheckforOnlyAllow.length > 0) {\n                let hasOnlyAllowedPackages = false;\n\n                toCheckforOnlyAllow.forEach((allowedLicense) => {\n                    if (currentLicense.indexOf(allowedLicense) >= 0) {\n                        hasOnlyAllowedPackages = true;\n                    }\n                });\n\n                if (!hasOnlyAllowedPackages) {\n                    console.error(\n                        `Package \"${packageName}\" is licensed under \"${currentLicense}\" which is not permitted by the --onlyAllow flag. Exiting.`,\n                    );\n\n                    process.exit(1);\n                }\n            }\n        }\n\n        function transformBSD(spdx) {\n            return spdx === 'BSD' ? '(0BSD OR BSD-2-Clause OR BSD-3-Clause OR BSD-4-Clause)' : spdx;\n        }\n\n        function invertResultOf(fn) {\n            return (spdx) => !fn(spdx);\n        }\n\n        function spdxIsValid(spdx) {\n            return spdxCorrect(spdx) === spdx;\n        }\n\n        function getLicenseMatch(licensesArr, filtered, packageName, packageData, compareLicenses) {\n            const validSPDXLicenses = compareLicenses.map(transformBSD).filter(spdxIsValid);\n            const invalidSPDXLicenses = compareLicenses.map(transformBSD).filter(invertResultOf(spdxIsValid));\n            const spdxExcluder = `( ${validSPDXLicenses.join(' OR ')} )`;\n\n            let match = false;\n\n            licensesArr.forEach((license) => {\n                /*istanbul ignore if - just for protection*/\n                if (license.indexOf(UNKNOWN) >= 0) {\n                    // Necessary due to colorization:\n                    filtered[packageName] = packageData;\n                } else {\n                    if (license.endsWith('*')) {\n                        license = license.slice(0, -1);\n                    }\n\n                    license = transformBSD(license);\n\n                    if (\n                        invalidSPDXLicenses.indexOf(license) >= 0 ||\n                        (spdxCorrect(license) &&\n                            validSPDXLicenses.length > 0 &&\n                            spdxSatisfies(spdxCorrect(license), spdxExcluder))\n                    ) {\n                        match = true;\n                    }\n                }\n            });\n\n            return match;\n        }\n\n        Object.keys(data)\n            .sort()\n            .forEach((item) => {\n                if (data[item].private) {\n                    data[item].licenses = colorizeString(UNLICENSED);\n                }\n\n                /*istanbul ignore next*/\n                if (!data[item].licenses) {\n                    data[item].licenses = colorizeString(UNKNOWN);\n                }\n\n                if (\n                    args.unknown &&\n                    data[item].licenses &&\n                    data[item].licenses !== UNKNOWN &&\n                    data[item].licenses.indexOf('*') > -1\n                ) {\n                    /*istanbul ignore if*/\n                    data[item].licenses = colorizeString(UNKNOWN);\n                }\n                /*istanbul ignore else*/\n                if (data[item]) {\n                    if (args.relativeModulePath && data[item].path != null) {\n                        // Cut the absolute portion of the module path (for forward and backward slashes respectively):\n                        data[item].path = data[item].path\n                            .replace(`${workingDir}/`, '')\n                            .replace(`${workingDir}\\\\`, '')\n                            .replace(workingDir, '');\n                    }\n\n                    if (args.onlyunknown) {\n                        if (data[item].licenses.indexOf('*') > -1 || data[item].licenses.indexOf(UNKNOWN) > -1) {\n                            sorted[item] = data[item];\n                        }\n                    } else {\n                        sorted[item] = data[item];\n                    }\n                }\n            });\n\n        if (!Object.keys(sorted).length) {\n            err = new Error('No packages found in this path...');\n        }\n\n        if (excludeLicenses || includeLicenses) {\n            if (excludeLicenses) {\n                Object.entries(sorted).forEach(([packageName, packageData]) => {\n                    let { licenses } = packageData;\n\n                    /*istanbul ignore if - just for protection*/\n                    if (!licenses) {\n                        filtered[packageName] = packageData;\n                    } else {\n                        const licensesArr = Array.isArray(licenses) ? licenses : [licenses];\n                        const licenseMatch = getLicenseMatch(\n                            licensesArr,\n                            filtered,\n                            packageName,\n                            packageData,\n                            excludeLicenses,\n                        );\n\n                        if (!licenseMatch) {\n                            filtered[packageName] = packageData;\n                        }\n                    }\n                });\n            }\n\n            if (includeLicenses) {\n                Object.entries(sorted).forEach(([packageName, packageData]) => {\n                    let { licenses } = packageData;\n\n                    /*istanbul ignore if - just for protection*/\n                    if (!licenses) {\n                        filtered[packageName] = packageData;\n                    } else {\n                        const licensesArr = Array.isArray(licenses) ? licenses : [licenses];\n                        const licenseMatch = getLicenseMatch(\n                            licensesArr,\n                            filtered,\n                            packageName,\n                            packageData,\n                            includeLicenses,\n                        );\n\n                        if (licenseMatch) {\n                            filtered[packageName] = packageData;\n                        }\n                    }\n                });\n            }\n        } else {\n            filtered = { ...sorted };\n        }\n\n        let resultJson = { ...filtered };\n\n        // package whitelist\n        const whitelist = getOptionArray(args.includePackages);\n        if (whitelist) {\n            resultJson = onlyIncludeWhitelist(whitelist, filtered);\n        }\n\n        // package blacklist\n        const blacklist = getOptionArray(args.excludePackages);\n        if (blacklist) {\n            resultJson = excludeBlacklist(blacklist, filtered);\n        }\n\n        // exclude by package name starting with a string\n        const excludeStartString = getOptionArray(args.excludePackagesStartingWith);\n        if (excludeStartString) {\n            resultJson = excludePackagesStartingWith(excludeStartString, filtered);\n        }\n\n        if (args.excludePrivatePackages) {\n            Object.keys(filtered).forEach(filterDeletePrivatePackages);\n        }\n\n        Object.keys(resultJson).forEach(exitIfCheckHits);\n\n        /*istanbul ignore next*/\n        if (err) {\n            debugError(err);\n            inputError = err;\n        }\n\n        // Return the callback and variables nicely\n        callback(inputError, resultJson);\n    });\n};\n\nexports.filterAttributes = function filterAttributes(attributes, json) {\n    let filteredJson = json;\n\n    if (attributes) {\n        filteredJson = {};\n        attributes.forEach((attribute) => {\n            filteredJson[attribute] = json[attribute];\n        });\n    }\n\n    return filteredJson;\n};\n\nexports.print = function print(sorted) {\n    console.log(exports.asTree(sorted));\n};\n\nexports.asTree = function asTree(sorted) {\n    return treeify.asTree(sorted, true);\n};\n\nexports.asSummary = function asSummary(sorted) {\n    const licenseCountMap = new global.Map();\n    const licenseCountArray = [];\n    const sortedLicenseCountObj = {};\n\n    Object.values(sorted).forEach(({ licenses }) => {\n        /*istanbul ignore else*/\n        if (licenses) {\n            licenseCountMap.set(licenses, licenseCountMap.get(licenses) + 1 || 1);\n        }\n    });\n\n    licenseCountMap.forEach((count, license) => {\n        licenseCountArray.push({ license, count });\n    });\n\n    /*istanbul ignore next*/\n    licenseCountArray\n        .sort((a, b) => b.count - a.count)\n        .forEach(({ license, count }) => {\n            sortedLicenseCountObj[license] = count;\n        });\n\n    return treeify.asTree(sortedLicenseCountObj, true);\n};\n\nexports.asCSV = function asCSV(sorted, customFormat, csvComponentPrefix) {\n    const csvHeaders = getCsvHeaders(customFormat, csvComponentPrefix);\n    const csvDataArr = getCsvData(sorted, customFormat, csvComponentPrefix);\n\n    return [csvHeaders, ...csvDataArr].join('\\n');\n};\n\n/**\n * Exports data as markdown (*.md) file which has it's own syntax.\n * @method\n * @param  {JSON} sorted       The sorted JSON data from all packages.\n * @param  {JSON} customFormat The custom format with information about the needed keys.\n * @return {String}            The returning plain text.\n */\nexports.asMarkDown = function asMarkDown(sorted, customFormat) {\n    let text = [];\n\n    if (customFormat && Object.keys(customFormat).length > 0) {\n        Object.keys(sorted).forEach((sortedItem) => {\n            text.push(` - **[${sortedItem}](${sorted[sortedItem].repository})**`);\n\n            Object.keys(customFormat).forEach((customItem) => {\n                text.push(`    - ${customItem}: ${sorted[sortedItem][customItem]}`);\n            });\n        });\n    } else {\n        Object.keys(sorted).forEach((key) => {\n            const module = sorted[key];\n            text.push(`[${key}](${module.repository}) - ${module.licenses}`);\n        });\n    }\n\n    return text.join('\\n');\n};\n\n/**\n * Output data in plain vertical format like Angular CLI does: https://angular.io/3rdpartylicenses.txt\n */\nexports.asPlainVertical = function asPlainVertical(sorted) {\n    return Object.entries(sorted)\n        .map(([moduleName, moduleData]) => {\n            let licenseText =\n                moduleName.substring(0, moduleName.lastIndexOf('@')) +\n                ' ' +\n                moduleName.substring(moduleName.lastIndexOf('@') + 1) +\n                '\\n';\n\n            if (Array.isArray(moduleData.licenses) && moduleData.licenses.length > 0) {\n                licenseText += moduleData.licenses.map((moduleLicense) => {\n                    /*istanbul ignore else*/\n                    if (typeof moduleLicense === 'object') {\n                        /*istanbul ignore next*/\n                        return moduleLicense.type || moduleLicense.name;\n                    }\n\n                    if (typeof moduleLicense === 'string') {\n                        return moduleLicense;\n                    }\n                });\n            } else if (\n                typeof moduleData.licenses === 'object' &&\n                (moduleData.licenses.type || moduleData.licenses.name)\n            ) {\n                licenseText += getLicenseTitle(moduleData.licenses.type || moduleData.licenses.name);\n            } else if (typeof moduleData.licenses === 'string') {\n                licenseText += getLicenseTitle(moduleData.licenses);\n            }\n\n            licenseText += '\\n';\n\n            if (Array.isArray(moduleData.licenseFile) && moduleData.licenseFile.length > 0) {\n                licenseText += moduleData.licenseFile.map((moduleLicense) => {\n                    /*istanbul ignore else*/\n                    if (typeof moduleLicense === 'object') {\n                        /*istanbul ignore next*/\n                        return moduleLicense.type || moduleLicense.name;\n                    }\n\n                    if (typeof moduleLicense === 'string') {\n                        return moduleLicense;\n                    }\n                });\n            } else if (\n                typeof moduleData.licenseFile === 'object' &&\n                (moduleData.licenseFile.type || moduleData.licenseFile.name)\n            ) {\n                licenseText += moduleData.licenseFile.type || moduleData.licenseFile.name;\n            } else if (typeof moduleData.licenseFile === 'string') {\n                licenseText += fs.readFileSync(moduleData.licenseFile, { encoding: 'utf8' });\n            }\n\n            return licenseText;\n        })\n        .join('\\n\\n');\n};\n\nexports.parseJson = function parseJson(jsonPath) {\n    if (typeof jsonPath !== 'string') {\n        return new Error('The path was not specified for the JSON file to parse.');\n    }\n\n    try {\n        const jsonFileContents = fs.readFileSync(jsonPath, { encoding: 'utf8' });\n\n        return JSON.parse(jsonFileContents);\n    } catch (err) {\n        return err;\n    }\n};\n\nexports.asFiles = function asFiles(json, outDir) {\n    mkdirp.sync(outDir);\n\n    Object.keys(json).forEach((moduleName) => {\n        const licenseFile = json[moduleName].licenseFile;\n\n        if (licenseFile && fs.existsSync(licenseFile)) {\n            const fileContents = fs.readFileSync(licenseFile);\n            const outPath = path.join(outDir, `${moduleName}-LICENSE.txt`);\n            const baseDir = path.dirname(outPath);\n\n            mkdirp.sync(baseDir);\n            fs.writeFileSync(outPath, fileContents, 'utf8');\n        } else {\n            console.warn(`No license file found for module '${moduleName}'`);\n        }\n    });\n};\n\nfunction getCsvHeaders(customFormat, csvComponentPrefix) {\n    const prefixName = '\"component\"';\n    const entriesArr = [];\n\n    if (csvComponentPrefix) {\n        entriesArr.push(prefixName);\n    }\n\n    if (customFormat && Object.keys(customFormat).length > 0) {\n        entriesArr.push('\"module name\"');\n\n        Object.keys(customFormat).forEach((item) => {\n            entriesArr.push(`\"${item}\"`);\n        });\n    } else {\n        ['\"module name\"', '\"license\"', '\"repository\"'].forEach((item) => {\n            entriesArr.push(item);\n        });\n    }\n\n    return entriesArr.join(',');\n}\n\nfunction getCsvData(sorted, customFormat, csvComponentPrefix) {\n    const csvDataArr = [];\n\n    Object.entries(sorted).forEach(([key, module]) => {\n        const dataElements = [];\n\n        if (csvComponentPrefix) {\n            dataElements.push(`\"${csvComponentPrefix}\"`);\n        }\n\n        //Grab the custom keys from the custom format\n        if (customFormat && Object.keys(customFormat).length > 0) {\n            dataElements.push(`\"${key}\"`);\n\n            Object.keys(customFormat).forEach((item) => {\n                dataElements.push(`\"${module[item]}\"`);\n            });\n        } else {\n            dataElements.push([`\"${key}\"`, `\"${module.licenses || ''}\"`, `\"${module.repository || ''}\"`]);\n        }\n\n        csvDataArr.push(dataElements.join(','));\n    });\n\n    return csvDataArr;\n}\n\nfunction getOptionArray(option) {\n    return (Array.isArray(option) && option) || (typeof option === 'string' && option.split(';')) || false;\n}\n"]}