shell.which returns object
See original GitHub issueNode version (or tell us if you’re using electron or some other framework):
Using Shell.js in an Atom (1.34) plugin, => Electron 2.0.12
ShellJS version (the most recent version/Github branch you see the bug on):
0.8.3
Operating system:
macOS
Description of the bug:
shell.which('command') returns an object instead of a string
Example ShellJS command to reproduce the error:
const test = shell.which('git')
console.log(typeof test) // yields 'object' instead of 'string'
Current workaround (hack) until fix is available
let test = shell.which('git')
if (test) {
test = JSON.parse(JSON.stringify(test))
}
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
How to manipulate what `shell.which()` returns? - Stack Overflow
How can I manipulate what shell.which() returns? One approach that I could take would be to manipulate require('shelljs') to load my own fork...
Read more >Shell object (Shldisp.h) - Win32 apps | Microsoft Learn
Creates and returns a ShellWindows object. This object represents a collection of all of the open windows that belong to the Shell.
Read more >2. Shell Command Language
The shell performs redirection (see Redirection) and removes redirection operators and their operands from the parameter list. The shell executes a function ( ......
Read more >Bash Reference Manual - GNU.org
The return value is the exit status of the last command in commands that is executed, or false if any of the expressions...
Read more >Child process | Node.js v19.3.0 Documentation
child_process.exec() : spawns a shell and runs a command within that shell, ... it returns a Promise for an Object with stdout and...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

By design, this returns a ShellString. For your use-case, just call
shell.which('git').toString().@nfischer thanks a lot!