{
  "version": 3,
  "sources": ["../../../../src/packages/plugin-commands-script-runners/regexpCommand.ts"],
  "sourcesContent": ["import { PnpmError } from '../error/index.ts';\n\nexport function tryBuildRegExpFromCommand(command: string): RegExp | null {\n  // https://github.com/stdlib-js/regexp-regexp/blob/6428051ac9ef7c9d03468b19bdbb1dc6fc2a5509/lib/regexp.js\n  // eslint-disable-next-line optimize-regex/optimize-regex\n  const regExpDetectRegExpScriptCommand = /^\\/((?:\\\\\\/|[^/])+)\\/([dgimuvys]*)$/;\n\n  const match = command.match(regExpDetectRegExpScriptCommand);\n\n  // if the passed script selector is not in the format of RegExp literal like /build:.*/, return null and handle it as a string script command\n  if (!match) {\n    return null;\n  }\n\n  // if the passed RegExp script selector includes flag, report the error because RegExp flag is not useful for script selector and pnpm does not support this.\n  if (typeof match[2] !== 'undefined') {\n    throw new PnpmError(\n      'UNSUPPORTED_SCRIPT_COMMAND_FORMAT',\n      'RegExp flags are not supported in script command selector'\n    );\n  }\n\n  try {\n    const m = match[1];\n\n    if (typeof m !== 'string') {\n      return null;\n    }\n\n    return new RegExp(m);\n  } catch {\n    return null;\n  }\n}\n"],
  "mappings": "AAAA,SAAS,iBAAiB;AAEnB,SAAS,0BAA0B,SAAgC;AAGxE,QAAM,kCAAkC;AAExC,QAAM,QAAQ,QAAQ,MAAM,+BAA+B;AAG3D,MAAI,CAAC,OAAO;AACV,WAAO;AAAA,EACT;AAGA,MAAI,OAAO,MAAM,CAAC,MAAM,aAAa;AACnC,UAAM,IAAI;AAAA,MACR;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,MAAI;AACF,UAAM,IAAI,MAAM,CAAC;AAEjB,QAAI,OAAO,MAAM,UAAU;AACzB,aAAO;AAAA,IACT;AAEA,WAAO,IAAI,OAAO,CAAC;AAAA,EACrB,QAAQ;AACN,WAAO;AAAA,EACT;AACF;",
  "names": []
}
