https://github.com/kysely/locate-executable
Locate executable files for specific commands
https://github.com/kysely/locate-executable
binary electron electron-builder executable locate nodejs path
Last synced: about 2 months ago
JSON representation
Locate executable files for specific commands
- Host: GitHub
- URL: https://github.com/kysely/locate-executable
- Owner: kysely
- License: mit
- Created: 2017-07-22T02:48:36.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-08-21T19:57:08.000Z (almost 9 years ago)
- Last Synced: 2025-10-27T04:52:00.874Z (7 months ago)
- Topics: binary, electron, electron-builder, executable, locate, nodejs, path
- Language: JavaScript
- Size: 16.6 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Locate Executable [](https://badge.fury.io/js/locate-executable)
#### Locate executable files for specific commands (useful for `child_process` inside Electron apps)
After building an Electron app using `electron-builder`, the `$PATH` variable inside `child_process` may get set to `/usr/bin:/bin:/usr/sbin:/sbin` which makes it virtually impossible to spawn additional non-UNIX commands.
This package allows you to locate paths of executable files for such commands. You can then use these paths to spawn `child_process` inside the compiled app.
## Install
*Tested on macOS only. Let me know if it does/not work on Linux/Windows.*
```sh
npm install --save locate-executable
```
## `locateExecutable(command[,subpath][,callback])`
Looks for executable files for specified `command` in user's home directory recursively. You can narrow down the search by specifying additional `subpath`.
- `command` (String) Command you need the executable of
- `subpath` (String) *(optional)* Specify a particular subpath you want to look at
- `callback` (Function) *(optional)*
- `error` (String)
- `paths` (Array) List of absolute paths to executables
```javascript
// Example
import locateExecutable from 'locate-executable'
locateExecutable('jupyter-console', (error, paths) => {
if (error) console.log(error)
console.log(paths)
return
})
```
NOTE: As the search inside the home directory recursively can take some time, consider running it only on the first launch and saving the paths persistently in something like [`electron-store`](https://www.npmjs.com/package/electron-store).
## Contribute
So if you're awesome and want to contribute to this project, go fork, clone and send pull requests! These are the tips for features to work on:
- support for Windows and Linux (if it already doesn't work)
## License
MIT