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GAAc,EAAK,WAAW,MAC9E,CAEA,SAAS,yBAA0B,EAAa,GAC9C,OAAO,EAAM,QAAO,IAAS,KAAK,GAAa,GAAc,EAAK,WAAW,MAC/E,CAEA,SAAS,YAAa,EAAO,GAC3B,QAAQ,IAAI,yCACZ,EAAM,KAAI,GAAQ,QAAQ,IAAI,KAC9B,QAAQ,IAAI,IACZ,QAAQ,IAAI,6CACZ,EAAS,KAAI,GAAQ,QAAQ,IAAI,IACnC,CAEA,SAAS,WAAY,EAAO,GAC1B,QAAQ,IAAI,KAAK,UAAU,CAAC,QAAO,aACrC,CAEA,SAAS,cAAe,EAAe,GACrC,MAAM,EAAe,OAAO,KAAK,EAAe,aAChD,OAAO,QAAQ,IAAI,CAAC,iBAAiB,EAAe,GAAU,gBAAgB,KAC3E,MAAK,IACJ,MAAM,EAAQ,iBAAiB,EAAQ,KAAM,EAAQ,IAC/C,EAAQ,mBAAmB,OAAO,QAAQ,GAAe,EAAQ,IAGvE,MAAO,CAAC,MAFM,oBAAoB,EAAO,GAE1B,SADE,yBAAyB,EAAO,GAC1B,GAE7B,CA1EA,cAAc,UAAW,IAAI,OAC1B,MAAK,EAAE,QAAO,eACb,OAAQ,IAAI,MAAM,QAChB,IAAK,QACH,OAAO,YAAY,EAAO,GAC5B,IAAK,OACH,OAAO,WAAW,EAAO,GAE7B,MAAM,IAAI,MAAM,mBAAmB,IAAI,MAAM,SAAQ,IAEtD,OAAM,IACL,QAAQ,MAAM,kDAAkD,cAChE,QAAQ,MAAM,EAAG","file":"/npm/@sirbrillig/getphpcscoverage@1.1.0/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@sirbrillig/getphpcscoverage@1.1.0/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","#!/usr/bin/env node\n\nconst readPath = require('recursive-readdir')\nconst xml2js = require('xml2js')\nconst fs = require('fs')\nconst { get, some } = require('lodash')\nconst fsPath = require('path')\nconst meow = require('meow')\n\nconst parser = new xml2js.Parser()\nconst cli = meow(`\n  Usage\n    $ getphpcscoverage [directoryPath]\n\n  Specify a directory path which contains a phpcs.xml config file. This will\n  report the files which will be scanned by the config file and those that will\n  not.\n\n  Options\n    --help, -h  Show this help message\n    --version, -v  Show the version\n    --type <type>, -t <type>  Only examine files with this type extension (php, js, etc.)\n    --format <format>, -f <format>  Set output type (human, json)\n    --ignore <pattern>, -i <pattern>  Ignore files matching this pattern\n`, {\n  flags: {\n    version: {\n      type: 'boolean',\n      alias: 'v',\n      default: false\n    },\n    help: {\n      type: 'boolean',\n      alias: 'h',\n      default: false\n    },\n    type: {\n      type: 'string',\n      alias: 't',\n      default: 'php'\n    },\n    format: {\n      type: 'string',\n      alias: 'f',\n      default: 'human'\n    },\n    ignore: {\n      type: 'string',\n      alias: 'i',\n      default: ''\n    }\n  }\n})\n\nif (cli.flags.help) {\n  cli.showHelp()\n  // showHelp automatically exits\n}\nif (cli.flags.version) {\n  cli.showVersion()\n  // showVersion automatically exits\n}\n\nconst targetDir = cli.input[0] || '.'\nscanDirectory(targetDir, cli.flags)\n  .then(({found, notFound}) => {\n    switch (cli.flags.format) {\n      case 'human':\n        return humanReport(found, notFound)\n      case 'json':\n        return jsonReport(found, notFound)\n    }\n    throw new Error(`Unknown format: ${cli.flags.format}`)\n  })\n  .catch(err => {\n    console.error(`An error occurred while scanning the directory ${targetDir}:`)\n    console.error(err)\n  })\n\nfunction getFilesFromXml (xmlFilePath) {\n  return new Promise((resolve, reject) => {\n    fs.readFile(xmlFilePath, (err, data) => {\n      if (err) {\n        return reject(err)\n      }\n      parser.parseString(data, (err, result) => {\n        if (err) {\n          return reject(err)\n        }\n        resolve(get(result, 'ruleset.file', []))\n      })\n    })\n  })\n}\n\nfunction getFilesFromPath (directoryPath, options) {\n  const ignoreFiles = options.ignore ? [ `*${options.ignore}*` ] : []\n  return readPath(directoryPath, ignoreFiles)\n}\n\nfunction prependPathToPaths (prepend, paths) {\n  return paths.map(path => fsPath.join(prepend, path))\n}\n\nfunction filterByFileType (type, paths) {\n  return paths.filter(path => path.endsWith(type))\n}\n\nfunction filterByParentPaths (parentPaths, paths) {\n  return paths.filter(file => some(parentPaths, parentPath => file.startsWith(parentPath)))\n}\n\nfunction filterWithoutParentPaths (parentPaths, paths) {\n  return paths.filter(file => !some(parentPaths, parentPath => file.startsWith(parentPath)))\n}\n\nfunction humanReport (found, notFound) {\n  console.log('These files WILL be scanned by phpcs:')\n  found.map(file => console.log(file))\n  console.log('')\n  console.log('These files WILL NOT be scanned by phpcs:')\n  notFound.map(file => console.log(file))\n}\n\nfunction jsonReport (found, notFound) {\n  console.log(JSON.stringify({found, notFound}))\n}\n\nfunction scanDirectory (directoryPath, options) {\n  const phpcsXmlPath = fsPath.join(directoryPath, 'phpcs.xml')\n  return Promise.all([getFilesFromPath(directoryPath, options), getFilesFromXml(phpcsXmlPath)])\n    .then(results => {\n      const files = filterByFileType(options.type, results[0])\n      const paths = prependPathToPaths(fsPath.dirname(phpcsXmlPath), results[1])\n      const found = filterByParentPaths(paths, files)\n      const notFound = filterWithoutParentPaths(paths, files)\n      return {found, notFound}\n    })\n}\n"]}