{
  "version": 3,
  "sources": ["../../src/posix.ts", "../../src/win32.ts", "../../src/index.ts"],
  "sourcesContent": ["/**\n * This is the Posix implementation of isexe, which uses the file\n * mode and uid/gid values.\n *\n * @module\n */\n\nimport { Stats, statSync } from 'node:fs'\nimport { stat } from 'node:fs/promises'\nimport { IsexeOptions } from './options.js'\n\n/**\n * Determine whether a path is executable according to the mode and\n * current (or specified) user and group IDs.\n */\nexport const isexe = async (\n  path: string,\n  options: IsexeOptions = {},\n): Promise<boolean> => {\n  const { ignoreErrors = false } = options\n  try {\n    return checkStat(await stat(path), options)\n  } catch (e) {\n    const er = e as NodeJS.ErrnoException\n    if (ignoreErrors || er.code === 'EACCES') return false\n    throw er\n  }\n}\n\n/**\n * Synchronously determine whether a path is executable according to\n * the mode and current (or specified) user and group IDs.\n */\nexport const sync = (\n  path: string,\n  options: IsexeOptions = {},\n): boolean => {\n  const { ignoreErrors = false } = options\n  try {\n    return checkStat(statSync(path), options)\n  } catch (e) {\n    const er = e as NodeJS.ErrnoException\n    if (ignoreErrors || er.code === 'EACCES') return false\n    throw er\n  }\n}\n\nconst checkStat = (stat: Stats, options: IsexeOptions) =>\n  stat.isFile() && checkMode(stat, options)\n\nconst checkMode = (stat: Stats, options: IsexeOptions) => {\n  const myUid = options.uid ?? process.getuid?.()\n  const myGroups = options.groups ?? process.getgroups?.() ?? []\n  const myGid = options.gid ?? process.getgid?.() ?? myGroups[0]\n  if (myUid === undefined || myGid === undefined) {\n    throw new Error('cannot get uid or gid')\n  }\n\n  const groups = new Set([myGid, ...myGroups])\n\n  const mod = stat.mode\n  const uid = stat.uid\n  const gid = stat.gid\n\n  const u = parseInt('100', 8)\n  const g = parseInt('010', 8)\n  const o = parseInt('001', 8)\n  const ug = u | g\n\n  return !!(\n    mod & o ||\n    (mod & g && groups.has(gid)) ||\n    (mod & u && uid === myUid) ||\n    (mod & ug && myUid === 0)\n  )\n}\n", "/**\n * This is the Windows implementation of isexe, which uses the file\n * extension and PATHEXT setting.\n *\n * @module\n */\n\nimport { Stats, statSync } from 'node:fs'\nimport { stat } from 'node:fs/promises'\nimport { IsexeOptions } from './options.js'\nimport { delimiter } from 'node:path'\n\n/**\n * Determine whether a path is executable based on the file extension\n * and PATHEXT environment variable (or specified pathExt option)\n */\nexport const isexe = async (\n  path: string,\n  options: IsexeOptions = {},\n): Promise<boolean> => {\n  const { ignoreErrors = false } = options\n  try {\n    return checkStat(await stat(path), path, options)\n  } catch (e) {\n    const er = e as NodeJS.ErrnoException\n    if (ignoreErrors || er.code === 'EACCES') return false\n    throw er\n  }\n}\n\n/**\n * Synchronously determine whether a path is executable based on the file\n * extension and PATHEXT environment variable (or specified pathExt option)\n */\nexport const sync = (\n  path: string,\n  options: IsexeOptions = {},\n): boolean => {\n  const { ignoreErrors = false } = options\n  try {\n    return checkStat(statSync(path), path, options)\n  } catch (e) {\n    const er = e as NodeJS.ErrnoException\n    if (ignoreErrors || er.code === 'EACCES') return false\n    throw er\n  }\n}\n\nconst checkPathExt = (path: string, options: IsexeOptions) => {\n  const { pathExt = process.env.PATHEXT || '' } = options\n  const peSplit = pathExt.split(delimiter)\n  if (peSplit.indexOf('') !== -1) {\n    return true\n  }\n\n  for (const pes of peSplit) {\n    const p = pes.toLowerCase()\n    const ext = path.substring(path.length - p.length).toLowerCase()\n\n    if (p && ext === p) {\n      return true\n    }\n  }\n  return false\n}\n\nconst checkStat = (stat: Stats, path: string, options: IsexeOptions) =>\n  stat.isFile() && checkPathExt(path, options)\n", "import * as posix from './posix.js'\nimport * as win32 from './win32.js'\nexport * from './options.js'\nexport { win32, posix }\n\nconst platform = process.env._ISEXE_TEST_PLATFORM_ || process.platform\nconst impl = platform === 'win32' ? win32 : posix\n\n/**\n * Determine whether a path is executable on the current platform.\n */\nexport const isexe = impl.isexe\n/**\n * Synchronously determine whether a path is executable on the\n * current platform.\n */\nexport const sync = impl.sync\n"],
  "mappings": "0FAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,WAAAE,EAAA,SAAAC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SACxDC,EAAOD,IAAa,QAAUE,EAAQC,EAK/BC,EAAQH,EAAK,MAKbI,EAAOJ,EAAK",
  "names": ["posix_exports", "__export", "isexe", "sync", "statSync", "stat", "path", "options", "ignoreErrors", "checkStat", "e", "er", "checkMode", "myUid", "myGroups", "myGid", "groups", "mod", "uid", "gid", "u", "g", "o", "ug", "win32_exports", "__export", "isexe", "sync", "statSync", "stat", "delimiter", "path", "options", "ignoreErrors", "checkStat", "e", "er", "checkPathExt", "pathExt", "peSplit", "pes", "p", "ext", "platform", "impl", "win32_exports", "posix_exports", "isexe", "sync"]
}
