{"id":15373149,"url":"https://github.com/otiai10/lookpath","last_synced_at":"2025-04-12T22:36:31.501Z","repository":{"id":34650616,"uuid":"182180357","full_name":"otiai10/lookpath","owner":"otiai10","description":"The minimum and most straightforward way to check if command exists and where the executable is, without spawning child_process.","archived":false,"fork":false,"pushed_at":"2025-04-01T07:50:38.000Z","size":1117,"stargazers_count":63,"open_issues_count":5,"forks_count":8,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-04T02:07:57.658Z","etag":null,"topics":["binary","command","executable","exists","nodejs","path","where","which"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/lookpath","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/otiai10.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["otiai10"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2019-04-19T01:22:01.000Z","updated_at":"2025-02-26T14:36:21.000Z","dependencies_parsed_at":"2023-02-17T03:01:04.207Z","dependency_job_id":"c10c721b-1bc3-46cc-83f8-0d0276e01639","html_url":"https://github.com/otiai10/lookpath","commit_stats":{"total_commits":198,"total_committers":7,"mean_commits":"28.285714285714285","dds":"0.41414141414141414","last_synced_commit":"07929839ea8f90514d4f3075f43f695314089f10"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/otiai10%2Flookpath","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/otiai10%2Flookpath/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/otiai10%2Flookpath/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/otiai10%2Flookpath/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/otiai10","download_url":"https://codeload.github.com/otiai10/lookpath/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248642854,"owners_count":21138352,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["binary","command","executable","exists","nodejs","path","where","which"],"created_at":"2024-10-01T13:54:24.163Z","updated_at":"2025-04-12T22:36:31.470Z","avatar_url":"https://github.com/otiai10.png","language":"TypeScript","readme":"# lookpath\n\n[![npm version](https://badge.fury.io/js/lookpath.svg)](https://badge.fury.io/js/lookpath)\n[![npm download](https://img.shields.io/npm/dt/lookpath.svg)](https://www.npmjs.com/package/lookpath)\n[![Node.js CI](https://github.com/otiai10/lookpath/workflows/Node.js%20CI/badge.svg)](https://github.com/otiai10/lookpath/actions/)\n[![CodeQL](https://github.com/otiai10/lookpath/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/otiai10/lookpath/actions/workflows/codeql-analysis.yml)\n[![codecov](https://codecov.io/gh/otiai10/lookpath/branch/master/graph/badge.svg)](https://codecov.io/gh/otiai10/lookpath)\n[![Maintainability](https://api.codeclimate.com/v1/badges/1cc9237695a7bd8e3d60/maintainability)](https://codeclimate.com/github/otiai10/lookpath/maintainability)\n[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fotiai10%2Flookpath.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fotiai10%2Flookpath?ref=badge_shield)\n\nTo check if the command exists and where the executable file is, **WITHOUT** using `child_process`.\n\n```\nnpm install lookpath\n```\n\n# Example usage\n\n```js\nconst { lookpath } = require('lookpath');\n\nconst p = await lookpath('bash');\n// \"/bin/bash\", otherwise \"undefined\"\n```\n\n# Advanced usage\n\n```js\nconst p = await lookpath('bash', {\n  include: ['/home/hiromu/.bin'],\n  exclude: ['/mnt']\n});\n// include: Do scan also under `~/.bin`\n// exclude: Do NOT scan under `/mnt`\n```\n\n# Motivation\n\n- I don't want to spawn `child_process` in order to kick `which`, `where`, `whereis`, or `command -v`.\n    - [node.js - Node - check existence of command in path - Stack Overflow](https://stackoverflow.com/questions/34953168/node-check-existence-of-command-in-path/)\n    - [Node.js: Check if a command exists - Gist](https://gist.github.com/jmptable/7a3aa580efffdef50fa9f0dd3d068d6f)\n    - [mathisonian/command-exists: node module to check if a command-line command exists - GitHub](https://github.com/mathisonian/command-exists)\n- then I checked Go implementation of [`exec.LookPath`](https://golang.org/pkg/os/exec/#LookPath).\n    - [src/os/exec/lp_unix.go - The Go Programming Language](https://golang.org/src/os/exec/lp_unix.go?s=928:970#L24)\n- so I concluded that scanning under `$PATH` or `$Path` is the best straightforward way to check if the command exists.\n\n\n# Issues\n\n- https://github.com/otiai10/lookpath/issues\n\nAny feedback would be appreciated ;)\n\n\n# License\n\n[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fotiai10%2Flookpath.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fotiai10%2Flookpath?ref=badge_large)","funding_links":["https://github.com/sponsors/otiai10"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fotiai10%2Flookpath","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fotiai10%2Flookpath","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fotiai10%2Flookpath/lists"}